[Shapelib] Using Shapelib in VC++ .NET

Frank Warmerdam warmerdam at pobox.com
Tue May 11 10:04:09 EDT 2004

Andrew Cooper wrote:
> Hi,
> First I would like to thank you for offering this library to the public, 
> and it is greatly appreciated.
> My problem:
> I am new to shapelib and ArcView itself.  I am developing a VC++ .NET 
> windows application for converting a file into an ArcView shapefile.  I 
> am glad to have come across this library, but I am having a few problems.
> I have #include "shapelib.h", "shpopen.c", and "dbfopen.c" to my project 
> (first off, I don’t know if that is the correct way to add them).  Since 
> dbfopen.c and dbfopen.c have some of the same functions, I am getting 
> redifinition errors.  I have actually successfully created the .shp and 
> .shx files before I added the "dbfopen.c" file to my project.  
> Basically, I need to know how to properly interface the shapelib library 
> with my project.


You mention that dbfopen.c and dbfopen.c have some of the same functions.
I assume that is some sort of typo, since they are the same file.

There shouldn't be any conflicts between shpopen.c and dbfopen.c.   Can
you be more specific about the error messages you are getting?  Just
pulling shapefil.h (not shapelib.h, another typo?), dbfopen.c and shpopen.c
into your project should be fine.

> Another question:
> Is it possible for ArcView to automatically determine a projection (I 
> believe that is what they are called in ArcView) based on decimal degree 
> coordinates (or UTM) and to make a zoom to best fit a point shapefile?  
> Would it be possible to code that functionality? Also, is there a way to 
> create layers outside of ArcView?

You can write out a .prj file with a coordinate system definition for
ArcView to "know" the coordinate system.  But from the shapefile itself
you can't control stuff about the default view as far as I know.
ArcView 3.x layer definitions are kept in a text project file.  It is
possible to manipulate these externally but it is not a trivial effort
and not one for which Shapelib provides any support.

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