Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Created July 21, 2022 12:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ThomasG77/45b4a3866a6b2fb1b634d9930ca57546 to your computer and use it in GitHub Desktop.
Generation GeoJSON des mairies avec code INSEE
wget -N -P data/ http://files.opendatarchives.fr/professionnels.ign.fr/adminexpress/ADMIN-EXPRESS-COG_3-1__SHP__FRA_WM_2022-04-15.7z
cd data
7z e ADMIN-EXPRESS-COG_3-1__SHP__FRA_WM_2022-04-15.7z CHFLIEU_COMMUNE.* COMMUNE.* -r
ogr2ogr -overwrite \
-f GeoJSON \
-dialect SQLite \
-sql "SELECT \"INSEE_COM\", CASE WHEN chf.geometry IS NULL THEN 'c' ELSE 'm' END AS t, CASE WHEN chf.geometry IS NULL THEN PointOnSurface(\"COMMUNE\".geometry) ELSE chf.geometry END AS geometry FROM \"COMMUNE\" LEFT JOIN 'CHFLIEU_COMMUNE.shp'.\"CHFLIEU_COMMUNE\" chf ON chf.\"ID_COM\" = \"COMMUNE\".\"ID\"" \
chflieu_commune.geojson \
COMMUNE.shp \
-lco RFC7946=YES \
-lco WRITE_NAME=NO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment