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 }



  • 2
    Welcome to SE.GIS forum. Have a look similar question gis.stackexchange.com/questions/13762/… – Sunil Aug 8 '13 at 10:54
  • Thanks for welcoming :) I had gone through that link before posting. I do not want to use FME, want to do it using FWTools for linux. I had converted wkt to shapefile earlier that was quite satisfactory, but now I have the same data in geoJSON format instead of wkt. and need to have the shp file, while i try to do i get the errors ; – sidd.k Aug 8 '13 at 12:29
  • I'm voting to keep it open, as the linked question does not answer this question. – Devdatta Tengshe Aug 8 '13 at 16:54
  • The conversion of your test data works fine for me with ogr2ogr versions 1.9.2 and 1.10. A shapefile with 1 polygon is created without any errors. Your "FWTools for linux" might be too old. What does ogr2ogr --version say? – Hermann Aug 24 '13 at 6:29
  • 1
    The --version switch didn't yet exist in the version of ogr2ogr that was distributed with FWTools 2.0.6 I am also guessing that it didn't yet support GeoJSON either. 2.0.6 is really old (~2006), is there a reason that you can't use a modern version of GDAL? – DavidF Sep 5 '13 at 4:44

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)

| improve this answer | |
  • 4
    To get the most out of the Geojson, I would suggest to run the same for the points too (and lines, if you have any in the Geojson). That way you get two or three shapefiles out of one Geojson. – AndreJ Nov 16 '13 at 16:09
  • @AndreJoost I'm agree with you, this was just an example. I update the answer considering your suggestion. Thanks. – Antonio Falciano Nov 16 '13 at 16:37
  • 2
    not a solution, but I've had good luck using an online tool built with ogr2ogr: ogre.adc4gis.com – JasonBK Nov 26 '14 at 15:08

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.