Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ lib/data/spatial/forest_types_gl
lib/data/spatial/forest_types_ju
lib/data/spatial/forest_types_lu
lib/data/spatial/forest_types_ne
lib/data/spatial/forest_types_sz
lib/data/spatial/forest_types_sg
lib/data/spatial/forest_types_sh
lib/data/spatial/forest_types_so
Expand Down
2 changes: 2 additions & 0 deletions lib/data/spatial/1-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ _import "Download manually" "forest_types_so" "forest_types_so" "forest_types_so
_import "Download manually" "forest_types_gl" "forest_types_gl" "forest_types_gl"

_import "Download manually" "forest_types_ar" "forest_types_ar" "forest_types_ar"

_import "Download manually" "forest_types_sz" "forest_types_sz" "forest_types_sz"
19 changes: 19 additions & 0 deletions lib/data/sql/export_spatial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ WITH altitudinal_zones_cantonal AS
FROM forest_types_ar
WHERE hs_code IS NOT NULL and geom is not null
GROUP BY hs_code, hsue_code)
UNION
(SELECT
ST_Union(geom) AS geom,
CASE hsue_code is null
WHEN TRUE THEN hs_code::text
ELSE hs_code::text || '(' || hsue_code::text || ')'
END AS code,
hs_code::text as code_style
FROM forest_types_sz
WHERE hs_code IS NOT NULL and geom is not null
GROUP BY hs_code, hsue_code)
)foo )

SELECT (code::TEXT || subcode::TEXT)::text AS code, (code::TEXT || subcode::TEXT)::text AS code_style,
Expand Down Expand Up @@ -327,5 +338,13 @@ SELECT nais AS code,
nais as code_so,
null as info_vd
FROM forest_types_ar
WHERE nais IS NOT NULL and geom is not null
UNION
SELECT nais AS code,
ST_Transform(geom, 3857) as geometry,
nais as code_vd,
nais as code_so,
null as info_vd
FROM forest_types_sz
WHERE nais IS NOT NULL and geom is not null;

43 changes: 34 additions & 9 deletions lib/data/sql/import_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_ju', 'geom', '0',
'', 'forest_types_ju', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1334,7 +1334,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_bl', 'geom', '0',
'', 'forest_types_bl', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1353,7 +1353,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_vd', 'geom', '0',
'', 'forest_types_vd', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1370,7 +1370,31 @@ ADD
SELECT
AddGeometryColumn(
'', 'altitudinal_zones_vd', 'geom',
'0', 'MULTIPOLYGON', 2
'2056', 'MULTIPOLYGON', 2
);
----------------------------------------------
-- Forest types SZ
CREATE TABLE "forest_types_sz" (
"fid" serial,
"sz_einheit" varchar(80),
"nais" varchar(80),
"nais1" varchar(80),
"nais2" varchar(80),
"mo" numeric,
"ue" numeric,
"tahs" varchar(80),
"tahsue" varchar(80),
"hs_code" numeric,
"hsue_code" integer
);
ALTER TABLE
"forest_types_sz"
ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_sz', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
-- Forest types SG
Expand All @@ -1392,7 +1416,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_sg', 'geom', '0',
'', 'forest_types_sg', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1415,7 +1439,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_sh', 'geom', '0',
'', 'forest_types_sh', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1435,7 +1459,7 @@ ADD
PRIMARY KEY (gid);
SELECT
AddGeometryColumn(
'', 'forest_types_so', 'geom', '0',
'', 'forest_types_so', 'geom', '2056',
'MULTIPOLYGON', 2
);
----------------------------------------------
Expand All @@ -1461,7 +1485,7 @@ CREATE TABLE "forest_types_gl" (gid serial,
"hsue_code" float8);

ALTER TABLE "forest_types_gl" ADD PRIMARY KEY (gid);
SELECT AddGeometryColumn('','forest_types_gl','geom','0','MULTIPOLYGON',2);
SELECT AddGeometryColumn('','forest_types_gl','geom', '2056','MULTIPOLYGON',2);


----------------------------------------------
Expand All @@ -1482,7 +1506,7 @@ CREATE TABLE "forest_types_ar" (gid serial,
"hsue_code" float8);

ALTER TABLE "forest_types_ar" ADD PRIMARY KEY (gid);
SELECT AddGeometryColumn('','forest_types_ar','geom','0','MULTIPOLYGON',2);
SELECT AddGeometryColumn('','forest_types_ar','geom', '2056','MULTIPOLYGON', 2);



Expand Down Expand Up @@ -3247,4 +3271,5 @@ COPY ecograms
FROM
'/data/ecograms.csv' DELIMITER ';' CSV HEADER;

DROP SCHEMA IF EXISTS export CASCADE;
CREATE SCHEMA export;