Skip to content

Commit

Permalink
add veg load job
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Mar 8, 2024
1 parent 4da47da commit 7b9bbe0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Additional internal tables are created by model scripts.

From repository root, with $DATABASE_URL connection defined as db superuser:

.jobs/setup
jobs/setup
38 changes: 38 additions & 0 deletions jobs/whse_forest_vegetation.veg_comp_lyr_r1_poly
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -euxo pipefail

# download file
curl -o /tmp/VEG_COMP_LYR_R1_POLY_$year.gdb.zip
https://pub.data.gov.bc.ca/datasets/02dba161-fdb7-48ae-a4bb-bd6ef017c36d/current/VEG_COMP_LYR_R1_POLY_$year.gdb.zip

ogr2ogr \
-progress \
--config PG_USE_COPY YES \
-t_srs EPSG:3005 \
-dim XY \
-f PostgreSQL \
PG:$DATABASE_URL \
-overwrite \
-lco GEOMETRY_NAME=geom \
-lco SPATIAL_INDEX=NONE \
-lco FID=FEATURE_ID \
-lco FID64=TRUE \
-nln whse_forest_vegetation.veg_comp_lyr_r1_poly \
/tmp/VEG_COMP_LYR_R1_POLY_$year.gdb.zip \
VEG_COMP_LYR_R1_POLY

# index columns of interest
psql -v ON_ERROR_STOP=1 $DATABASE_URL -c \
"CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (for_mgmt_land_base_ind); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (inventory_standard_cd); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (non_productive_descriptor_cd); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (species_pct_1); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (species_cd_1); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (site_index); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (bclcs_level_1); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (bclcs_level_2); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (bclcs_level_3); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (bclcs_level_4); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (bclcs_level_5); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly (map_id); \
CREATE INDEX ON whse_forest_vegetation.veg_comp_lyr_r1_poly USING GIST (geom);"

0 comments on commit 7b9bbe0

Please sign in to comment.