[Shapelib] question about dbf file

Frank Warmerdam fwarmerdam at gmail.com
Tue May 17 09:45:15 EDT 2005

On 5/17/05, vijay sambhe <sambhe2005 at yahoo.com> wrote:
> Warmerdam, 
> I am using your shapelib and dgnlib to convert dgn file to shape file.
> I have successfully converted graphics part to shape file. I am just
> creating
> dbf files and not adding anything to it. My dgn elements have attributes
> (those
> hexa values) for database linkage. How to write dbf file for each shape
> element based on these hexa values. I have hexa values ready from customized
> dgnlib.


The version of dbf file used with shapefiles does not support
true binary data.  You could just convert the raw binary data
into hexadecimal numeric format (perhaps you already did), and
then store this in a string field in the .dbf file.

> I have never used arc info.. I dont know the structure of
> dbf file. do I have to define a table structure first in dbf file and then
> add those corresponding integer values for each shape type. 

Yes, you wll need to define any fields you want in your .dbf file
before adding any records.  You can sort of get the hang of this
from the dbfcreate.c and dbfadd.c example programs that create 
a dbf file and add fields. 

> After doing this
> how the link is established between shape element and its corresponding data
> in dbf file. is it automatic. 

It is an implied correspondence based on order.  So shape "0" in 
the shapefile corresponds with record "0" in the .dbf file and so on.
Just make sure that you add one, and only one record to the .dbf
file for each shape you add in the shapefile. 

> If I indentify shape element will it show its
> corresponding data in arcinfo interface .. if not what procedure I have to
> follow to have this link up with customized table data in dbf file. 

If you use the appropriate modes in a shapefile supporting application
such as ArcView, ArcGIS or OpenEV  you should be able to see
the attributes of a shapefile when you have selected that feature. 

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 Shapelib mailing list