[Gdal-dev] creating shape files
bmarchand at ara.com
Tue Jul 29 08:29:34 EDT 2003
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.
From: Brian Marchand
Sent: Monday, July 28, 2003 3:00 PM
To: gdal-dev at remotesensing.org
Subject: [Gdal-dev] creating shape files
I am new at using the OGR classes in GDAL and I'm attempting to read a
shape file, change the projection, and then write the modified data to a
new file. When the new shape files get created the dbf file has no
fields in it. When I trace through the code I see that the dbf file gets
populated from a OGRFeatureDefn object in the OGRShapeLayer class. This
seems to get initialized when the layer is created but it never gets
set. Even after creating multiple features in the layer. Then when
reading the shape file it fails because the nRecords member in the
DBFHandle class is zero.
How do I apply a feature definition to a newly created layer?
Since the layer has an association to just one OGRFeatureDefn object,
can I assume that all the features in a layer are required to have the
same feature definition?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gdal-dev