I am trying to run ogr2ogr to convert some geojson to shapefile. All is good until any of the geojson features have an invalid geometry (for example, the coordinate array of point geometry is empty).

I included the -skipfailures flag, but ogr2ogr quits as soon as it hits the first invalid feature. Am I not doing something wrong here?

Example ogr2ogr call:

ogr2ogr -skipfailures -f "ESRI Shapefile" myshape.shp mygeojson.geojson

3 Answers 3


Try adding -nlt geometry to your ogr script:

ogr2ogr -skipfailures -f "ESRI Shapefile" myshape.shp mygeojson.geojson -nlt geometry

I've experienced the problem you describe using ogr2ogr to translate datasets containing both singlepart and multipart features in the same layer; for example, POINT and MULTIPOINT, LINE AND MULTILINE, and POLYGON and MULTIPOLYGON.

By default, OGR wants you to obey convention and use only one feature-type per dataset. If you break the rule, OGR will throw a generic error and recommend the -skipfailures flag. This can be misleading if the real issue is mixed/matched geometries in the same layer.

Since ESRI shapefile does allow single/multipart features in the same layer, you need to realize OGR may throw this error even if you have valid geometries. In that scenario you have two options: 1) Convert multipart features to singlepart (which ogr can do via the -explodecollections flag), or 2) use the -nlt flag and specify GEOMETRY as the option. The -nlt GEOMETRY option allows you to combine a mixture of feature types in the same layer. Of course, as a consequence, OGR won't won't protect best practices.

If your GeoJSON file "started life" as an ESRI shapefile, it's possible that you have both POINT and MULTIPOINT features contained in that dataset, in which case you might be encountering this issue even with valid points.

  • This is a really frustrating limitation. If you want to retain (multi)polygons and ignore points, as determined with -nlt MULTIPOLYGON -nlt PROMOTE_TO_MULTI, ogr2ogr will error on input with geometry collections of mixed types. -skipfailures makes precisely no difference. -explodecollections doesn't help there either. Aug 29, 2023 at 22:12
 -skipfailures: Continue after a failure, skipping the failed feature.

One explanation for the behavior you're experiencing could be that all features in your geoJSON file are broken. Have you tested their validity, e.g. using QGIS "Check geometry validity"?

  • All of the other features are valid. If I fix the one point geometry described in my original post, all of the other geojson points get added to the output shapefile.
    – user890
    Aug 28, 2011 at 11:45

The intended behavior in my understanding is that if an invalid feature is encountered, it will be skipped and the conversion will continue with the next valid feature rather than stopping.

It appears that you are doing everything properly, so I don't know what's wrong! Have you tried going to a different format just to see if that works?

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.