Skip to main content
Update the command supplied in the answer with the command that ended up working for me
Source Link

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry),name,place,source,boundary,admin_level,tiger:revieved from invalid"OGRGeoJSON" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it took awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry),name,place,source,boundary,admin_level,tiger:revieved from invalid" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it took awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry),name,place,source,boundary,admin_level from OGRGeoJSON" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it took awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

Write complete SQL
Source Link
user30184
  • 69k
  • 4
  • 71
  • 125

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry),name,place,source,boundary,admin_level,tiger:revieved from invalid" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it tooltook awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry) from invalid" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it tool awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry),name,place,source,boundary,admin_level,tiger:revieved from invalid" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it took awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP

Source Link
user30184
  • 69k
  • 4
  • 71
  • 125

It should be possible to make your GeoJSON file valid with ogr2ogr http://www.gdal.org/ogr2ogr.html by using OGR SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html which supports all the Spatialite functions https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html includind MakeValid. Unfortunately the function is very new in SpatiaLite and using it would require a special GDAL version that is compiled with SpatiaLite development version from the trunk.

The usage would be close to this untested command:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT MakeValid(geometry) from invalid" corrected.json invalid.json

I think I could fix your invalid GeoJSON but it tool awhile to find a program and format that opens the invalid polygon.

  • Convert invalid GeoJSON to OpenJUMP JML format. This was necessary because OpenJUMP did not open the invalid GeoJSON directly but it did not complain about invalid JML

ogr2ogr -f jml invalid.jml invalid.json

  • Open invalid.json with OpenJUMP

  • Correct the geometries by using the tool from menu Tools - QA - Make Geometries Valid

  • Save corrected layer in GeoJSON format with OpenJUMP