[Shapelib] Example of how to create a shapefile

Kleymeyer, Alan AKleymeyer at overwatch.com
Thu Mar 16 07:06:10 PST 2006

Thanks Frank.

After some search I finally found an example of someone using the
library so I added:

DBFField(..,FTINTEGER, 11, 0)
DBFWriteIntegerAttribute(hDBFile, 0, 0, 0)

Which did the trick.

It would be nice if this type of example was included somewhere in the
sample code.  The sample code included in the library is all cmdline
so I didn't find it helpful as a specific example of how to create a


-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of Frank
Sent: Wednesday, March 15, 2006 5:16 PM
To: Shapelib Development
Subject: Re: [Shapelib] Example of how to create a shapefile

On 3/15/06, Kleymeyer, Alan <AKleymeyer at overwatch.com> wrote:

> which appears to create the .SHP & .SHX just fine.
> However ArcMap fails to load it reporting "Error opening feature
> I assume because I haven't created a .DBF file.
> What exactly do I need to write to the .DBF file?


When I want to create a shapefile, but don't have any meaningful
attributes, I normally create a dbf file with one integer column that
I write an id to.   You can skim the dbfcreate and dbfadd programs
for a bit of an indication of how to use the dbf api.

Make sure you have one row in the dbf file for each shape object

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

Shapelib mailing list
Shapelib at lists.maptools.org

More information about the Shapelib mailing list