Skip to content

Instantly share code, notes, and snippets.

@esgn
Created April 17, 2024 11:57
Show Gist options
  • Save esgn/fa0bc22666a5107f8b30c14dd40ed4f0 to your computer and use it in GitHub Desktop.
Save esgn/fa0bc22666a5107f8b30c14dd40ed4f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Working area in EPSG:2154
xmin=892000
ymin=6249000
xmax=894000
ymax=6247000
rm -rf footprints
mkdir footprints
rm -f bdtopo.7z bdtopo.gpkg bati_bdtopo.gpkg
BDTOPO_URL="https://data.geopf.fr/telechargement/download/BDTOPO/BDTOPO_3-3_TOUSTHEMES_GPKG_LAMB93_R93_2023-12-15/BDTOPO_3-3_TOUSTHEMES_GPKG_LAMB93_R93_2023-12-15.7z"
wget -O bdtopo.7z $BDTOPO_URL
7z -r e bdtopo.7z */*/*/*.gpkg -so > bdtopo.gpkg
ogr2ogr footprints/bati_bdtopo.gpkg bdtopo.gpkg -dialect sqlite -sql "SELECT fid, geometrie FROM batiment WHERE ST_Contains(ST_GeomFromText('POLYGON(($xmin $ymin,$xmin $ymax,$xmax $ymax,$xmax $ymin,$xmin $ymin))'),geometrie)"
rm -f bdtopo.7z
rm -rf bdtopo.gpkg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment