28 lines
1.3 KiB
Bash
28 lines
1.3 KiB
Bash
|
|
sudo apt install unzip ogr2ogr
|
|
|
|
wget "https://www.data.gouv.fr/api/1/datasets/r/0e117c06-248f-45e5-8945-0e79d9136165" -O communes.shp.zip
|
|
unzip -o communes-shp.zip
|
|
ogr2ogr -f postgresql PG:"dbname=oedb" communes.shp -nln communes -nlt geometry
|
|
|
|
psql oedb -c "
|
|
create index communes_insee on communes (insee);
|
|
alter table communes drop ogc_fid;
|
|
alter table communes drop surf_ha;
|
|
"
|
|
|
|
wget "https://www.data.gouv.fr/datasets/contours-des-departements-francais-issus-d-openstreetmap/#/resources/eb36371a-761d-44a8-93ec-3d728bec17ce" -O departements-shp.zip
|
|
unzip -o departements-shp.zip
|
|
ogr2ogr -f postgresql PG:"dbname=oedb" departements-20230101.shp -nln departements -nlt geometry
|
|
|
|
psql oedb -c "
|
|
create index departements_insee on departements (insee);
|
|
alter table departements drop ogc_fid;
|
|
alter table departements drop surf_ha;
|
|
"
|
|
rm departements-*
|
|
|
|
# créer la table bison futé et importer les données
|
|
sudo -u postgres psql oedb -c "create table bison_fute_zones (dep text, zone text);"
|
|
sudo -u postgres psql oedb -c "\copy bison_fute_zones from bisonfute2016.csv with (format csv, header true);"
|
|
sudo -u postgres psql oedb -c "create materialized view bison_fute_geo as select zone, st_snaptogrid(st_union(wkb_geometry),0.00001) as geom FROM bison_fute_zones b join departements d on (d.insee=b.dep) group by 1;"
|