Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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"
}

]
}
share|improve this question
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 ; –  user3840550 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

1 Answer 1

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)

share|improve this answer
1  
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. –  afalciano Nov 16 '13 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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