[Gdal-dev] creating shape files

Frank Warmerdam warmerdam at pobox.com
Sat Aug 2 20:01:49 EDT 2003


Brian Marchand wrote:
> I’m going to answer my own questions starting with the second one. Yes 
> it appears that all features in a layer must all be using the same 
> feature definition. You can set this in the OGRLayer by, iterating 
> through the field definitions of the appropriate feature definition and 
> calling the CreateField method of the OGRLayer with each field 
> definition. This must be done before calling the CreateFeature method of 
> the layer otherwise the fields of the feature will not be added to the 
> dbf file. If this is not the preferred way to handle writing out 
> features please let me know.

Brian,

Your assumptions are correct.  All fields for a layer should be added
using CreateField() before any features are created on the layer.  For a
few formats it may be possible to add fields on populated layers, but this
is not generally possible.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list