views:

464

answers:

3

Does anyone have an experience in processing (reading) ESRI shapefiles (http://en.wikipedia.org/wiki/Shapefile) from C++?

I have found at least 2 open source libraries: ShapeLib C library (http://shapelib.maptools.org/) and OGR (http://www.gdal.org/ogr/). Which one is better? Does anybody used one of them? How about the experience?

+4  A: 

I've found them both to be ok, but I'd choose the ShapeLib library as ogr is a bit heavy/weird for its purpose.

The shapefile format is very simple; if you only have to access a specific/simple set of shapefiles you could consider reinventing the wheel and write the code to access them yourself. I've done this in an embedded app and it didn't take much more time then using these libs.

Tomas
Decided to use ShapeLib, thank you very much. In our case, it makes no sense to redevelop a code that has been already tested with wide variety of applications using the lib.
Sergey Borodavkin
Hi, sorry for my questions, just want know how to render the shapefiles ? I meaning is draw the map data ? any open source code can be use for this purpose ? Thanks for your reply .Regards
Robin
+1  A: 

The OGR Shapefile driver from GDAL/OGR directly uses implementation of Shapelib, so there is no difference actually. If you check the OGR source tree, you will find Shapelib files like shpopen.c and dbfopen.c.

Also, Frank Warmerdam is the author of both, Shapelib and OGR and I can confirm myself that Frank keeps the shpopen.c and dbfopen.c in synch between Shapelib and OGR.

To summary, there is no difference between Shapelib and OGR regarding the implementation of Shapefile format specification.

mloskot
A: 

I am new in Visual C++ or C++. I am wondering if anyone have read the shape files in Visual C++.

I appreciate your response.

tum

Tum
Yes, I have used Shapelib as well as OGR libraries with Visual C++. Submit new question if you have a specific problem you want to ask about. SO is not a threaded discussion forum!
mloskot