[gdal-dev] field name in ESRI file

Jason Roberts jason.roberts at duke.edu
Wed Mar 24 11:47:06 EDT 2010


Oz,

The specification that Peter refers to is http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. Also, check out the OGR Shapefile driver's documentation http://www.gdal.org/ogr/drv_shapefile.html. It documents this issue, as well as others that might be of interest. Finally, if you are interested in compatibility with ArcGIS, http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing%20considerations%20for%20shapefile%20output.

In my experience, it is very important to read the OGR driver documentation carefully for whatever data format you're working with. The driver may exhibit different behavior than the original applications designed to work with that format. For example, the OGR shapefile driver documentation states that the default width for integer fields is 11 characters, which is the width required to fully represent 32-bit signed integers, yet the last link I mentioned above states that ArcGIS limits the width to 9 characters. You may want to carefully investigate issues like that if you are interested in compatibility with ArcGIS.

Finally, the OGR driver documentation may occasionally document something better than the original documentation for the format. For example, the OGR shapefile driver documentation makes mention of storing dates in shapefiles. ArcGIS also supports storing dates in shapefiles yet ESRI's whitepaper makes no mention that shapefiles support dates.

Best,

Jason

-----Original Message-----
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Peter J Halls
Sent: Wednesday, March 24, 2010 11:15 AM
To: Oz Nahum
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] field name in ESRI file

Oz,

   shapefiles use the dBase IV format .dbf file for attributes: this defines the 
maximum field name width to be 10 characters - 'LAND USE CODE' has 13.  Also, 
space characters are not permitted - use underscore '_' instead.  Whilst GDAL 
may create the field names as you have specified, other packages may not accept 
them as input.  I believe that the Shapefile rules are still available as a 
White Paper on the ESRI.com website: it is worth reading the document to 
understand what is possible.

Best wishes,

Peter

Oz Nahum wrote:
> Hello GDAL Devs,
> 
> I encoutered a small problem, where I don't understand why field names in
> ESRI Shape files created by gdal, are truncated.
> Here is a code snippet:
> 
>     field_LUC = ogr.FieldDefn()
>     field_LUC.SetName('LAND USE CODE')
>     field_LUC.SetType(ogr.OFTInteger)
>     field_LUC.SetWidth(15)
>     dst_layer.CreateField(field_LUC)
> 
> 
> Yet, when I examine the output file the attribute table contains  a field
> called "LAND USE C",
> so 3 characters are missing.
> 
> Would be happy to know what am I doing wrong. Thank you very much,
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
--------------------------------------------------------------------------------
Peter J Halls, GIS Advisor, University of York
Telephone: 01904 433806     Fax: 01904 433740
Snail mail: Computing Service, University of York, Heslington, York YO10 5DD
This message has the status of a private and personal communication
--------------------------------------------------------------------------------
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list