[Shapelib] Example of how to create a shapefile

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


Thanks Frank.

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

DBFCreate
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
driven
so I didn't find it helpful as a specific example of how to create a
shapefile.

Alan

-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of Frank
Warmerdam
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
class"
>
> I assume because I haven't created a .DBF file.
>
> What exactly do I need to write to the .DBF file?

Alan,

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
created.

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
http://lists.maptools.org/mailman/listinfo/shapelib





More information about the Shapelib mailing list