Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Created July 6, 2022 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/0cc87a1ca00b8df4c9a96a679d74241e to your computer and use it in GitHub Desktop.
Save ThomasG77/0cc87a1ca00b8df4c9a96a679d74241e to your computer and use it in GitHub Desktop.
Fix QPV validity
wget https://sig.ville.gouv.fr/Atlas/qp-politiquedelaville-shp.zip
unzip qp-politiquedelaville-shp.zip
ogrinfo QP_METROPOLEOUTREMER_WGS84_EPSG4326.shp -dialect SQLite -sql "SELECT count(*) FROM \"QP_METROPOLEOUTREMER_WGS84_EPSG4326\" WHERE NOT IsValid(geometry)"
ogr2ogr out.shp QP_METROPOLEOUTREMER_WGS84_EPSG4326.shp -dialect SQLite -sql "SELECT \"CODE_QP\", \"NOM_QP\", \"COMMUNE_QP\", CASE WHEN NOT IsValid(geometry) THEN ST_MakeValid(geometry) ELSE geometry END AS geometry FROM \"QP_METROPOLEOUTREMER_WGS84_EPSG4326\""
ogrinfo out.shp -dialect SQLite -sql "SELECT count(*) FROM out WHERE NOT IsValid(geometry)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment