mirror of
https://github.com/dataforcanada/d4c-datapkg-statistical.git
synced 2026-06-13 14:10:55 +02:00
Initial commit
This commit is contained in:
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
if [ ! -d "${DATA_FOLDER}/health_regions" ]
|
||||
then
|
||||
echo "Making directory ${DATA_FOLDER}/health_regions/"
|
||||
mkdir -p ${DATA_FOLDER/health_regions/{input,extracted,output}
|
||||
fi
|
||||
|
||||
aria2c -x16 --out=hr2024001.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2024001/hrbf-flrs/digi/ArcGIS/HR_000a23a_e.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2023001.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2023001/hrbf-flrs/digi/ArcGIS/HR_000a22a_e.zip?st=P3vL0l_a" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2018001.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2018001/data-donnees/boundary-limites/arcinfo/HR_000a18a-eng.zip?st=NgmRAZb7" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2017001.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2017001/data-donnees/boundary-limites/arcinfo/HR_000a17a_e.zip?st=i4-a3s-U" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2015002.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2015002/data-donnees/boundary-limites/arcinfo/HRP000b11a_e.zip?st=pdmD3cVj" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2015001.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2015001/data-donnees/boundary-limites/arcinfo/HRP000b11a_e.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2013003.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2013003/data-donnees/boundary-limites/arcinfo/HRP000b11a_e.zip?st=yEQLGVii" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2013002.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2013002/data-donnees/boundary-limites/arcinfo/HRP000b11a_e.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2013001.zip "https://www150.statcan.gc.ca/pub/82-402-x/2011001/data-donnees/boundary-limites/arcinfo/hr000b06p-eng.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2011001.zip "https://www150.statcan.gc.ca/pub/82-402-x/2011001/data-donnees/boundary-limites/arcinfo/hr000b06p-eng.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2009001.zip "https://www150.statcan.gc.ca/pub/82-402-x/2009001/data-donnees/boundary-limites/arcinfo/hr000b08pz-eng.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2007001.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2007001/data/boundary/arcinfo/HR000b07PZ.zip?st=hCrYIpzu" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2006001.zip "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2006001/data/boundary/arcview/lhr000b05pz.zip?st=TEqojTk8" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2005001.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2005001/data/boundary/arcview/lhr000b05pz.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2004001.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2004001/data/boundary/arcview/hr000b.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
aria2c -x16 --out=hr2003001.zip "https://www150.statcan.gc.ca/n1/pub/82-402-x/2004001/data/boundary/arcview/hr000b.zip" --dir=${DATA_FOLDER}/health_regions/input --auto-file-renaming=false
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
import_to_postgis() {
|
||||
local filepath=$1
|
||||
local table_name=$2
|
||||
local extra_parameters=${@:3}
|
||||
|
||||
# Virtual file system
|
||||
if [[ ${filepath: -4} = '.zip' ]]; then
|
||||
local filepath="/vsizip/${filepath}"
|
||||
fi
|
||||
|
||||
echo "Importing ${filepath}"
|
||||
ogr2ogr \
|
||||
--config PG_USE_COPY YES \
|
||||
-overwrite \
|
||||
-f "PostgreSQL" \
|
||||
"PG:host=db dbname=${POSTGRES_DB} user=${POSTGRES_USER} password=${POSTGRES_PASSWORD} port=5432" \
|
||||
-lco GEOMETRY_NAME=geom \
|
||||
-progress \
|
||||
-gt 500000 \
|
||||
-t_srs EPSG:4326 \
|
||||
-nln ${table_name} \
|
||||
${extra_parameters} \
|
||||
${filepath}
|
||||
}
|
||||
|
||||
INPUT_FOLDER="${DATA_FOLDER}/health_regions/input"
|
||||
EXTRACTED_FOLDER="${DATA_FOLDER}/health_regions/extracted"
|
||||
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2024001.zip statcan_hr2024001_tmp "-nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2023001.zip statcan_hr2023001_tmp "-nlt PROMOTE_TO_MULTI"
|
||||
unzip -n ${INPUT_FOLDER}/hr2018001.zip -d ${EXTRACTED_FOLDER}
|
||||
import_to_postgis ${EXTRACTED_FOLDER}/HR_000a18a_e/HR_000a18a_e.shp statcan_hr2018001_tmp "-select HR_UID,ENGNAME,FRENAME -nlt PROMOTE_TO_MULTI"
|
||||
unzip -n ${INPUT_FOLDER}/hr2017001.zip -d ${EXTRACTED_FOLDER}
|
||||
import_to_postgis ${EXTRACTED_FOLDER}/HR_000a17a_e/HR_000a17a_e_Dec2017.shp statcan_hr2017001_tmp "-select HR_UID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2015002.zip statcan_hr2015002_tmp "-nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2015001.zip statcan_hr2015001_tmp "-select HR_UID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2013003.zip statcan_hr2013003_tmp "-select HR_UID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2013002.zip statcan_hr2013002_tmp "-select HR_UID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2013001.zip statcan_hr2013001_tmp "-select PR_HRUID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2011001.zip statcan_hr2011001_tmp "-select PR_HRUID,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2009001.zip statcan_hr2009001_tmp "-select HRUID2007,ENG_LABEL,FRE_LABEL -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2007001.zip statcan_hr2007001_tmp "-select PR_HRUID,HRNAME,FRNAME -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2006001.zip statcan_hr2006001_tmp "-select PR_HRUID,HRNAME,FRNAME -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2005001.zip statcan_hr2005001_tmp "-select PR_HRUID,HRNAME,FRNAME -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2004001.zip statcan_hr2004001_tmp "-select PR_HRUID,HRNAME -nlt PROMOTE_TO_MULTI"
|
||||
import_to_postgis ${INPUT_FOLDER}/hr2003001.zip statcan_hr2003001_tmp "-select PR_HRUID,HRNAME -nlt PROMOTE_TO_MULTI"
|
||||
@@ -0,0 +1,126 @@
|
||||
-- TODO
|
||||
-- 2022 Health Regions;
|
||||
drop table if exists statcan_hr_2022;
|
||||
create table statcan_hr_2022 as
|
||||
select hr_uid, engname, frename, dguid, wkb_geometry as geom
|
||||
from statcan_hr2023001_tmp;
|
||||
|
||||
create index statcan_hr_2022_geom_idx on statcan_hr_2022 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2023001_tmp;
|
||||
|
||||
-- 2018 Health Regions;
|
||||
drop table if exists statcan_hr_2018;
|
||||
create table statcan_hr_2018 as
|
||||
select hr_uid, engname, frename, concat('2018A007', hr_uid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2018001_tmp;
|
||||
|
||||
create index statcan_hr_2018_geom_idx on statcan_hr_2018 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2018001_tmp;
|
||||
|
||||
-- 2017 Health Regions;
|
||||
drop table if exists statcan_hr_2017;
|
||||
create table statcan_hr_2017 as
|
||||
select hr_uid, eng_label as engname, fre_label as frename, concat('2017A007', hr_uid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2017001_tmp;
|
||||
|
||||
create index statcan_hr_2017_geom_idx on statcan_hr_2017 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2017001_tmp;
|
||||
|
||||
-- 2015 Health Regions;
|
||||
drop table if exists statcan_hr_2015;
|
||||
create table statcan_hr_2015 as
|
||||
select hr_uid, eng_label as engname, fre_label as frename, concat('2015A007', hr_uid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2015002_tmp;
|
||||
|
||||
create index statcan_hr_2015_geom_idx on statcan_hr_2015 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2015002_tmp;
|
||||
|
||||
-- 2013 Health Regions;
|
||||
drop table if exists statcan_hr_2013;
|
||||
create table statcan_hr_2013 as
|
||||
select hr_uid, eng_label as engname, fre_label as frename, concat('2013A007', hr_uid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2013003_tmp;
|
||||
|
||||
create index statcan_hr_2013_geom_idx on statcan_hr_2013 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2013003_tmp;
|
||||
drop table if exists statcan_hr2013002_tmp;
|
||||
drop table if exists statcan_hr2013001_tmp;
|
||||
|
||||
-- 2011 Health Regions;
|
||||
drop table if exists statcan_hr_2011;
|
||||
create table statcan_hr_2011 as
|
||||
select pr_hruid as hr_uid, eng_label as engname, fre_label as frename, concat('2011A007', pr_hruid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2011001_tmp;
|
||||
|
||||
create index statcan_hr_2011_geom_idx on statcan_hr_2011 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2011001_tmp;
|
||||
|
||||
-- 2009 Health Regions;
|
||||
drop table if exists statcan_hr_2009;
|
||||
create table statcan_hr_2009 as
|
||||
select hruid2007 as hr_uid, eng_label as engname, fre_label as frename, concat('2009A007', hruid2007) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2009001_tmp;
|
||||
|
||||
create index statcan_hr_2009_geom_idx on statcan_hr_2009 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2009001_tmp;
|
||||
|
||||
-- 2007 Health Regions;
|
||||
drop table if exists statcan_hr_2007;
|
||||
create table statcan_hr_2007 as
|
||||
select distinct pr_hruid as hr_uid, hrname as engname, frname as frename, concat('2007A007', pr_hruid) as dguid, wkb_geometry as geom
|
||||
from statcan_hr2007001_tmp;
|
||||
|
||||
update statcan_hr_2007
|
||||
set frename = engname
|
||||
where frename is null;
|
||||
|
||||
create index statcan_hr_2007_geom_idx on statcan_hr_2007 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2007001_tmp;
|
||||
|
||||
-- 2006 Health Regions;
|
||||
drop table if exists statcan_hr_2006;
|
||||
create table statcan_hr_2006 as
|
||||
select distinct pr_hruid as hr_uid, hrname as engname, frname as frename, concat('2006A007', pr_hruid) as dguid, st_union(wkb_geometry) as geom
|
||||
from statcan_hr2006001_tmp
|
||||
group by pr_hruid, hrname, frname;
|
||||
|
||||
update statcan_hr_2006
|
||||
set frename = engname
|
||||
where frename is null;
|
||||
|
||||
create index statcan_hr_2006_geom_idx on statcan_hr_2006 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2006001_tmp;
|
||||
|
||||
-- 2005 Health Regions;
|
||||
drop table if exists statcan_hr_2005;
|
||||
create table statcan_hr_2005 as
|
||||
select distinct pr_hruid as hr_uid, hrname as engname, frname as frename, concat('2005A007', pr_hruid) as dguid, st_union(wkb_geometry) as geom
|
||||
from statcan_hr2005001_tmp
|
||||
group by pr_hruid, hrname, frname;
|
||||
|
||||
update statcan_hr_2005
|
||||
set frename = engname
|
||||
where frename is null;
|
||||
|
||||
create index statcan_hr_2005_geom_idx on statcan_hr_2005 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2005001_tmp;
|
||||
|
||||
-- 2004 Health Regions;
|
||||
drop table if exists statcan_hr_2004;
|
||||
create table statcan_hr_2004 as
|
||||
select distinct pr_hruid as hr_uid, hrname as engname, concat('2004A007', pr_hruid) as dguid, st_union(wkb_geometry) as geom
|
||||
from statcan_hr2004001_tmp
|
||||
group by pr_hruid, hrname;
|
||||
|
||||
create index statcan_hr_2004_geom_idx on statcan_hr_2004 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2004001_tmp;
|
||||
|
||||
-- 2003 Health Regions;
|
||||
drop table if exists statcan_hr_2003;
|
||||
create table statcan_hr_2003 as
|
||||
select distinct pr_hruid as hr_uid, hrname as engname, concat('2003A007', pr_hruid) as dguid, st_union(wkb_geometry) as geom
|
||||
from statcan_hr2003001_tmp
|
||||
group by pr_hruid, hrname;
|
||||
|
||||
create index statcan_hr_2003_geom_idx on statcan_hr_2003 using GIST(geom) with (FILLFACTOR=100);
|
||||
drop table if exists statcan_hr2003001_tmp;
|
||||
Reference in New Issue
Block a user