[Shapelib] .dbf files
Brian Peschel
brianp at occinc.com
Thu Jun 14 09:10:32 PDT 2007
Kemp Kernstine wrote:
>> How does one write records to a .dbf file for shapefiles. I am able
>> to create the .dbf file and write a field to the file using
>> DBFcreate() and DBFaddField() from the Shapelib, however there is no
>> write record function. Is this a function build into C? Do I need to
>> have a field for every record?
>>
>
> Just use one of DBFWrite* function with shape index pointing to
> new/next record position, and it will be created automatically
> (if it does not exists):
>
>
> // Calculate index of next (new) record
> iRecord = DBFGetRecordCount( hDBF );
>
> // Write value to 1st field and (implicitly) create new record
> DBFWriteStringAttribute(hDBF, iRecord, 0, "My data" );
>
> Cheers
>
I believe you need to call DBFClose(DBFHandle psDBF) for the data to
actually be written to the file.
- Brian
More information about the Shapelib
mailing list