What is the "D" type?

25 views
Skip to first unread message

jxb5000

unread,
May 9, 2013, 9:23:48 AM5/9/13
to geospati...@googlegroups.com
For PyShp, what is the meaning of the "D" type for fields in a .dbf file?
 
"D" for "double" or "D" for "date"?
 
If "D" is for "date", what is the proper type to use for a double-precision floating point number?
 
Thanks.

Joel Lawhead

unread,
May 9, 2013, 9:46:07 AM5/9/13
to geospati...@googlegroups.com
It's "date" stored in 8 bytes.  Although it's part of the dbf spec you may find that different GIS software and libraries handle it differently.  
Here's the format from the spec:

Date in format YYYYMMDD. A date like 0000-00- 00 is *NOT* valid.

Reference:


--
You received this message because you are subscribed to the Google Groups "Geospatial Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geospatialpyth...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Joel Lawhead, PMP
E-mail: jlaw...@geospatialpython.com
Web: GeospatialPython.com
Twitter: @SpatialPython

jxb5000

unread,
May 9, 2013, 10:45:33 AM5/9/13
to geospati...@googlegroups.com
Thanks, Joel.
So what is type for a double-precision floating point number?  Is it "N"?

Joel Lawhead

unread,
May 9, 2013, 12:22:35 PM5/9/13
to geospati...@googlegroups.com
If I remember correctly it's "F" as in float.

This should work:
import shapefile
w=shapefile.Writer(shapefile.POINT)
w.point(90.3, 30)
w.field('TEMP','F','8')
w.record("50.89")
w.save("float_example")

However I have a feeling the pyshp code doesn't try to do any casting or validation when reading or writing. So anything you put in there might not throw an error until you open it in something else.

I just ran the above sample and Microsoft Excel recognized the 50.89 correctly.

- Joel



--
You received this message because you are subscribed to the Google Groups "Geospatial Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geospatialpyth...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

jxb5000

unread,
May 13, 2013, 8:42:35 AM5/13/13
to geospati...@googlegroups.com
Yes, the "F" works.  Thanks!

On Thursday, May 9, 2013 9:23:48 AM UTC-4, jxb5000 wrote:
Reply all
Reply to author
Forward
0 new messages