I have a GeoJson file that I want to convert to ESRI Shapefile using ogr2ogr in FWTools.

I tried using

ogr2ogr -F "ESRI Shapefile" filename.shp geojsonfile.json OGRGeoJSON

I got output

ERROR 6: Can't create fields of type StringList on shapefile layers. ERROR 1: Attempt to write non-polygon (POINT) geometry to type shapefile. ERROR 1: Terminating translation prematurely after failed translation of layer OGRGeoJSON

GeoJSON input we are giving is in standard geojson format.

content of geojson are like {to share I took only a part from features array }




You have to force the SHP geometry type (because the geometry type of GeoJSON Geometry Collection is not supported in SHPs) and use the -skipfailures option:

ogr2ogr -nlt POINT -skipfailures points.shp geojsonfile.json OGRGeoJSON    
ogr2ogr -nlt LINESTRING -skipfailures linestrings.shp geojsonfile.json OGRGeoJSON
ogr2ogr -nlt POLYGON -skipfailures polygons.shp geojsonfile.json OGRGeoJSON

(Tested with GDAL 1.10.0, released 2013/04/24)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.