15

Does anyone have an experience in processing (reading) ESRI shapefiles from C++?

I have found at least 2 open source libraries: ShapeLib C library and OGR. Which one is better? Does anybody used one of them? How about the experience?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sergey Borodavkin
  • 285
  • 1
  • 3
  • 7

2 Answers2

23

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
mloskot
  • 37,086
  • 11
  • 109
  • 136
10

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
  • 5,067
  • 1
  • 35
  • 39
  • 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 Jan 27 '10 at 07:01
  • 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 – iXcoder May 15 '10 at 08:43
  • @Robin, your best bet to getting an answer to this question is to search the internet. The next best bet is to post this as a _separate question_ - comments are not the appropriate place to begin a new line of inquiry. – Richard Nov 06 '12 at 12:54