[gdal-dev] Missing features after copying layers from Shapefiles to SQLite

Nik Sands nixanz at nixanz.com
Sun Mar 2 17:18:18 PST 2014


Hi all,

I'm planning to switch from using a standard file format of Shapefiles to Spatialite for internal storage of spatial data.

When importing from other formats, the app attempts to convert these to SQLite (Spatialite) using 'OGR_DS_CopyLayer' to copy each layer from the source data set to a new layer in the new SQLite dataset.

However, when converting Shapefiles to SQLite, it only copies across about a third of the features for many of the layers and therefore the new data set is of no use.

The relevant code and output is below.

I'm at a loss to figure out what is going wrong here and I'd be grateful is somebody could assist in getting this to work as expected (or am I doing the wrong thing completely?).

NB:  This is using Spatialite on iOS (simulator).

When I use ogr2ogr on Mac OS X with SQLite (without Spatialite) it works fine and doesn't miss any features.

Cheers,
Nik.


CODE:

	OGRLayerH sourceLayer = OGR_DS_GetLayer(ds, i);
	int sourceFeatureCount = OGR_L_GetFeatureCount(sourceLayer, YES);

	OGR_DS_CopyLayer(destDS, sourceLayer, OGR_L_GetName(sourceLayer), NULL);

	OGRLayerH destLayer = OGR_DS_GetLayerByName(destDS, OGR_L_GetName(sourceLayer));
	printf("sourceFeatureCount:  %d\n", sourceFeatureCount);
	printf("  destFeatureCount:  %d\n", OGR_L_GetFeatureCount(destLayer, YES));

OUTPUT:

	sourceFeatureCount:  3882
	  destFeatureCount:  1200


More information about the gdal-dev mailing list