Skip to content

Why limited the length of field to 10? #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kuno opened this issue Jul 1, 2014 · 6 comments
Closed

Why limited the length of field to 10? #2

kuno opened this issue Jul 1, 2014 · 6 comments

Comments

@kuno
Copy link

kuno commented Jul 1, 2014

I am new to shapefile, I saw in this line of code
https://github.com/GeospatialPython/pyshp/blob/master/shapefile.py#L744

That you limited the lenght of the field to 10 at most, can you explain why?

@GeospatialPython
Copy link
Owner

The Dbf format limits fields to 10 characters. There are some derivative
formats that try to work around this limitation, but nearly all GIS
software truncates Dbf files to 10.

Some GIS software will handle longer fields with different database
formats. But shapefiles have a hard limit.

  • Joel

On Monday, June 30, 2014, kuno [email protected] wrote:

I am new to shapefile, I saw in this line of code
https://github.com/GeospatialPython/pyshp/blob/master/shapefile.py#L744

That you limited the lenght of the field to 10 at most, can you explain
why?


Reply to this email directly or view it on GitHub
#2.

Joel Lawhead, PMP
E-mail: [email protected]
Web: GeospatialPython.com http://geospatialpython.com/
Twitter: @SpatialPython

@kuno
Copy link
Author

kuno commented Jul 2, 2014

ok, very helpful.

Thanks.

@kuno kuno closed this as completed Jul 2, 2014
@jinz2014
Copy link

Dear Author,

In the dbf file format https://en.wikipedia.org/wiki/.dbf, the size of the field name is 11 bytes, not 10 bytes. Could it be fixed if it is a bug ?

Database field descriptor bytes

0-10 11 bytes Field name in ASCII (zero-filled)

Thank you for reading and reply.

@eldang
Copy link

eldang commented Mar 23, 2016

@jinz2014 the shapefile article spells out that the maximum length of a field name is only 10 characters. I don't know what the 11th byte is used for, but it's existence doesn't allow shapefiles to have 11 character field names.

It may be possible to hack something that lets people use longer field names within pyshp, but this stack exchange thread makes clear why that would be a bad idea.

@micahcochran
Copy link
Contributor

In DBF the 11th byte is a zero (00h) value, for null termination. It is probably the way to make seem to be somewhat like C null terminated strings. You might be able to use fscanf to read it in, which almost nobody would do today. Remember, dBase is a DOS format with design decision made back in the 1980s.

It is not a bug, its a feature! 😄

ESRI's ArcGIS software has aliases for field, which I assume is just in the map .MXD file for display to the end user.

@jinz2014
Copy link

Thank you for your answer.

From: Eldan Goldenberg [mailto:[email protected]]
Sent: Wednesday, March 23, 2016 3:27 PM
To: GeospatialPython/pyshp
Cc: JIN, ZHEMING
Subject: Re: [pyshp] Why limited the length of field to 10? (#2)

@jinz2014https://github.com/jinz2014 the shapefile articlehttps://en.wikipedia.org/wiki/Shapefile#Data_storage spells out that the maximum length of a field name is only 10 characters. I don't know what the 11th byte is used for, but it's existence doesn't allow shapefiles to have 11 character field names.

It may be possible to hack something that lets people use longer field names within pyshp, but this stack exchange threadhttps://gis.stackexchange.com/questions/15784/how-to-bypass-10-character-limit-of-field-name-in-shapefiles makes clear why that would be a bad idea.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-200530729

karimbahgat added a commit that referenced this issue Sep 24, 2016
Sync with geospatialpython master
karimbahgat added a commit that referenced this issue Dec 30, 2020
…l new tests

Previously field names that exceeded the 10 character limit were capped and written as the first 11 characters, although it should be capped to the first 10 characters and ended with a null-terminator. See #2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants