Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which C++ library for ESRI shapefiles to choose?

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?

like image 858
Sergey Borodavkin Avatar asked Jan 26 '10 12:01

Sergey Borodavkin


People also ask

What files are needed for a shapefile?

Shapefiles are composed of 3 mandatory files . shp, . shx and . dbf.

What is a Shx file ArcGIS?

shx—The index file that stores the index of the feature geometry; required. . dbf—The dBASE table that stores the attribute information of features; required. There is a one-to-one relationship between geometry and attributes, which is based on record number.

Is a shapefile proprietary?

The shapefile format is proprietary but open; its technical specifications are published and can be implemented and used freely. Largely as a result of ArcView's popularity, shapefile has become a de facto standard for creation and interchange of vector geospatial data.

What type of data are shapefiles?

A shapefile is a vector data file format commonly used for geospatial analysis. Shapefiles store the location, geometry, and attribution of point, line, and polygon features.


2 Answers

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.

like image 181
mloskot Avatar answered Sep 21 '22 13:09

mloskot


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.

like image 22
Tomas Avatar answered Sep 22 '22 13:09

Tomas