mirror of
https://github.com/dataforcanada/d4c-datapkg-statistical.git
synced 2026-06-13 14:10:55 +02:00
Create 2021 cartographic boundary files
This commit is contained in:
@@ -6,8 +6,9 @@ Census Divisions
|
||||
Definition here: https://web.archive.org/web/20250131082459/https://www12.statcan.gc.ca/census-recensement/2021/ref/dict/az/definition-eng.cfm?ID=geo008#moreinfo
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS silver.cd_2021;
|
||||
CREATE TABLE silver.cd_2021 AS
|
||||
-- Digital boundary;
|
||||
DROP TABLE IF EXISTS silver.cd_2021_digital;
|
||||
CREATE TABLE silver.cd_2021_digital AS
|
||||
SELECT DISTINCT
|
||||
pr.country_dguid,
|
||||
pr.country_en_name,
|
||||
@@ -31,7 +32,7 @@ SELECT DISTINCT
|
||||
cd.cdtype AS cd_type,
|
||||
cd.geom
|
||||
FROM
|
||||
silver.pr_2021 AS pr,
|
||||
silver.pr_2021_digital AS pr,
|
||||
bronze.lcd_000a21a_e AS cd,
|
||||
silver.dissemination_geographies_relationship_2021 AS dgr,
|
||||
bronze.lcar000a21a_e AS car
|
||||
@@ -42,16 +43,59 @@ WHERE
|
||||
|
||||
-- Make geometries valid
|
||||
UPDATE
|
||||
silver.cd_2021
|
||||
silver.cd_2021_digital
|
||||
SET
|
||||
geom = ST_MAKEVALID(geom)
|
||||
WHERE
|
||||
ST_ISVALID(geom) = 'f';
|
||||
|
||||
-- Create spatial index
|
||||
CREATE INDEX cd_2021_geom_idx ON silver.cd_2021
|
||||
CREATE INDEX cd_2021_digital_geom_idx ON silver.cd_2021_digital
|
||||
USING gist (geom) WITH (fillfactor = 100);
|
||||
|
||||
-- Cartographic boundary;
|
||||
DROP TABLE IF EXISTS silver.cd_2021_cartographic;
|
||||
CREATE TABLE silver.cd_2021_cartographic AS
|
||||
SELECT DISTINCT
|
||||
b.country_dguid,
|
||||
b.country_en_name,
|
||||
b.country_fr_name,
|
||||
b.country_en_abbreviation,
|
||||
b.country_fr_abbreviation,
|
||||
b.grc_dguid,
|
||||
b.grc_en_name,
|
||||
b.grc_fr_name,
|
||||
b.pr_dguid,
|
||||
b.pr_en_name,
|
||||
b.pr_fr_name,
|
||||
b.pr_en_abbreviation,
|
||||
b.pr_fr_abbreviation,
|
||||
b.pr_iso_code,
|
||||
b.car_dguid,
|
||||
b.car_en_name,
|
||||
b.car_fr_name,
|
||||
b.cd_dguid,
|
||||
b.cd_name,
|
||||
b.cd_type,
|
||||
a.geom
|
||||
FROM
|
||||
bronze.lcd_000b21a_e AS a,
|
||||
silver.cd_2021_digital AS b
|
||||
WHERE
|
||||
a.dguid = b.cd_dguid;
|
||||
|
||||
-- Make geometries valid
|
||||
UPDATE
|
||||
silver.cd_2021_cartographic
|
||||
SET
|
||||
geom = ST_MAKEVALID(geom)
|
||||
WHERE
|
||||
ST_ISVALID(geom) = 'f';
|
||||
|
||||
-- Create spatial index
|
||||
CREATE INDEX cd_2021_cartographic_geom_idx ON silver.cd_2021_cartographic
|
||||
USING gist (geom) WITH (fillfactor = 100);
|
||||
|
||||
/* 2016
|
||||
Definition here: https://web.archive.org/web/20250304001456/https://www12.statcan.gc.ca/census-recensement/2016/ref/dict/geo008-eng.cfm
|
||||
*/
|
||||
*/
|
||||
Reference in New Issue
Block a user