32

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 }

{"id":1223,
"properties":{"name":"3","level":2},
"map_version":11,"type":"FeatureCollection","x_id":1234,"obj_type":"LevelGeometry",
"features":[

{
"my_area":[131.40093253528894,33.58879853190332,6.515867411008615,3.490549810987222,-0.6237271428108215],
"id":1984791,
"location":{"type":"Point","coordinates":[131.4009325,33.5887985]},
"properties":{"display_name":"xyz"},
"type":"Feature",
"geometry":{"type":"Polygon","coordinates":[[[131.4009508,33.5888314],[131.4008895,33.5887946],[131.4009148,33.5887653],[131.4009761,33.5888020],[131.4009508,33.5888314]]]},
"obj_type":"Geometry"
}

]
}
0

1 Answer 1

35

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)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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