diff --git a/model/01_access/dams/sql/dams.sql b/model/01_access/dams/sql/dams.sql index ab10089a..a9aa5932 100644 --- a/model/01_access/dams/sql/dams.sql +++ b/model/01_access/dams/sql/dams.sql @@ -150,4 +150,16 @@ where cabd_id in ( 'ba5fe3eb-7bbe-45c1-b301-555872387c16', '8a6b10fa-0d4f-4c45-857c-764d7e8028f8', '48478e95-e063-4df6-a047-6aaf6087011b' -); \ No newline at end of file +); + +# report on dams that do not get matched to FWA streams +drop view if exists bcfishpass.dams_not_matched_to_streams; +create view bcfishpass.dams_not_matched_to_streams as +select + a.cabd_id, + a.dam_name_en +from cabd.dams a +left join bcfishpass.dams b +on a.cabd_id::text = b.dam_id +where b.dam_id is null +order by a.cabd_id; \ No newline at end of file diff --git a/reports/access/README.md b/reports/access/README.md deleted file mode 100644 index 22ac92e4..00000000 --- a/reports/access/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Access - -Summarize access model outputs - -## Usage - - psql $DATABASE_URL --csv -f sql/access_ch_cm_co_pk_sk.sql > access_ch_cm_co_pk_sk.csv - psql $DATABASE_URL --csv -f sql/access_st.sql > access_st.csv - -### Columns: - -| Name | Description | -|--------------------------|-------------| -| `streamnetwork_km` | Total stream network length (km) | -| `pa_total_km` | Length of stream network with no known natural barriers to given species downstream (ie, "potentially accessible") | -| `pa_nobarrier_km` | Length of potentially accessible stream with no known anthropogenic barrier downstream | -| `pa_potentialbarrier_km` | Length of potentially accessible stream with potential anthropogenic barrier(s) downstream (ie, culvert(s)) | -| `pa_knownbarrier_km` | Length of potentially accessible stream with assessed (PSCIS) barrier or dam (with no known fish passage structure) downstream | \ No newline at end of file diff --git a/reports/access/access_ch_cm_co_pk_sk.csv b/reports/access/access_ch_cm_co_pk_sk.csv deleted file mode 100644 index 93d9bae3..00000000 --- a/reports/access/access_ch_cm_co_pk_sk.csv +++ /dev/null @@ -1,10 +0,0 @@ -watershed_group_code,streamnetwork_km,pa_total_km,pa_nobarrier_km,pa_potentialbarrier_km,pa_knownbarrier_km -BOWR,6268.54,2557.59,1356.72,794.65,406.22 -BULK,14642.10,4864.17,2452.45,903.14,1508.59 -CARR,6206.48,400.15,296.80,103.35,0 -ELKR,12486.92,0,0,0,0 -LNIC,7299.99,1153.28,508.46,381.77,263.05 -LNTH,9261.85,1137.29,717.70,418.20,1.40 -MORR,9033.10,2676.74,1970.20,470.41,236.13 -PARS,13867.47,0,0,0,0 -QUES,12482.83,5262.26,3322.68,1939.58,0 diff --git a/reports/access/access_st.csv b/reports/access/access_st.csv deleted file mode 100644 index 60ea90a6..00000000 --- a/reports/access/access_st.csv +++ /dev/null @@ -1,10 +0,0 @@ -watershed_group_code,streamnetwork_km,pa_total_km,pa_nobarrier_km,pa_potentialbarrier_km,pa_knownbarrier_km -BOWR,6268.54,0,0,0,0 -BULK,14642.10,6016.98,2871.85,1217.72,1927.41 -CARR,6206.48,0,0,0,0 -ELKR,12486.92,0,0,0,0 -LNIC,7299.99,1897.17,566.04,697.33,633.80 -LNTH,9261.85,0,0,0,0 -MORR,9033.10,3273.53,2297.50,670.56,305.47 -PARS,13867.47,0,0,0,0 -QUES,12482.83,0,0,0,0 diff --git a/reports/access/sql/access_ch_cm_co_pk_sk.sql b/reports/access/sql/access_ch_cm_co_pk_sk.sql deleted file mode 100644 index 5e76ab43..00000000 --- a/reports/access/sql/access_ch_cm_co_pk_sk.sql +++ /dev/null @@ -1,10 +0,0 @@ -SELECT - watershed_group_code, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) / 1000)::numeric), 2), 0) AS streamnetwork_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS pa_total_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] and s.barriers_anthropogenic_dnstr is null) / 1000)::numeric), 2), 0) AS pa_nobarrier_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] and s.barriers_anthropogenic_dnstr is not null and s.barriers_pscis_dnstr is null) / 1000)::numeric), 2), 0) AS pa_potentialbarrier_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] and s.barriers_pscis_dnstr is not null) / 1000)::numeric), 2), 0) AS pa_knownbarrier_km -FROM bcfishpass.streams s -GROUP BY watershed_group_code -ORDER BY watershed_group_code; \ No newline at end of file diff --git a/reports/access/sql/access_st.sql b/reports/access/sql/access_st.sql deleted file mode 100644 index b72e6408..00000000 --- a/reports/access/sql/access_st.sql +++ /dev/null @@ -1,10 +0,0 @@ -SELECT - watershed_group_code, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) / 1000)::numeric), 2), 0) AS streamnetwork_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS pa_total_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] and s.barriers_anthropogenic_dnstr is null) / 1000)::numeric), 2), 0) AS pa_nobarrier_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] and s.barriers_anthropogenic_dnstr is not null and s.barriers_pscis_dnstr is null) / 1000)::numeric), 2), 0) AS pa_potentialbarrier_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] and s.barriers_pscis_dnstr is not null) / 1000)::numeric), 2), 0) AS pa_knownbarrier_km -FROM bcfishpass.streams s -GROUP BY watershed_group_code -ORDER BY watershed_group_code; \ No newline at end of file diff --git a/reports/crossings/sql/all_spawningrearing_per_barrier.sql b/reports/crossings/sql/all_spawningrearing_per_barrier.sql deleted file mode 100644 index edacfe09..00000000 --- a/reports/crossings/sql/all_spawningrearing_per_barrier.sql +++ /dev/null @@ -1,28 +0,0 @@ --- ELK River WCT specific reporting, run on crossings table only - -ALTER TABLE bcfishpass.crossings ADD COLUMN IF NOT EXISTS all_spawningrearing_per_barrier double precision DEFAULT 0; -COMMENT ON COLUMN bcfishpass.crossings.all_spawningrearing_per_barrier IS 'If the given barrier and all barriers downstream were remediated, the amount of connected spawning/rearing habitat that would be added, per barrier. (ie the sum of all_spawningrearing_belowupstrbarriers_km for all barriers, divided by n barriers)'; - - -WITH summary AS -( - SELECT - a.aggregated_crossings_id, - ROUND((SUM(b.all_spawningrearing_belowupstrbarriers_km) / (COALESCE(array_length(array_remove(a.barriers_anthropogenic_dnstr, '1100002536'), 1), 0) + 1))::numeric, 2) as all_spawningrearing_per_barrier - FROM bcfishpass.crossings a - INNER JOIN bcfishpass.crossings b - ON FWA_Downstream(a.blue_line_key, a.downstream_route_measure, a.wscode_ltree, a.localcode_ltree, b.blue_line_key, b.downstream_route_measure, b.wscode_ltree, b.localcode_ltree, true) - AND a.watershed_group_code = b.watershed_group_code - WHERE - a.watershed_group_code = :'wsg' AND - b.barrier_status IN ('BARRIER','POTENTIAL') AND - b.aggregated_crossings_id != '11e03b9a-0a3f-4022-b534-7e3de9eece2e' AND - a.all_spawningrearing_belowupstrbarriers_km != 0 AND - a.blue_line_key = a.watershed_key - GROUP BY a.aggregated_crossings_id -) - -UPDATE bcfishpass.crossings a -SET all_spawningrearing_per_barrier = b.all_spawningrearing_per_barrier -FROM summary b -WHERE a.aggregated_crossings_id = b.aggregated_crossings_id; \ No newline at end of file diff --git a/reports/crossings/sql/crossings_admin.sql b/reports/crossings/sql/crossings_admin.sql deleted file mode 100644 index 8bc5c601..00000000 --- a/reports/crossings/sql/crossings_admin.sql +++ /dev/null @@ -1,55 +0,0 @@ --- this takes a while to run, only do it when cutting a release - - -ALTER TABLE bcfishpass.crossings ADD COLUMN abms_regional_district text; -ALTER TABLE bcfishpass.crossings ADD COLUMN abms_municipality text; -ALTER TABLE bcfishpass.crossings ADD COLUMN clab_indian_reserve_name text; -ALTER TABLE bcfishpass.crossings ADD COLUMN clab_indian_reserve_band_name text; -ALTER TABLE bcfishpass.crossings ADD COLUMN clab_national_park text; -ALTER TABLE bcfishpass.crossings ADD COLUMN tantalis_park_ecores_pa text; -ALTER TABLE bcfishpass.crossings ADD COLUMN pmbc_private text; -ALTER TABLE bcfishpass.crossings ADD COLUMN adm_nr_region text; -ALTER TABLE bcfishpass.crossings ADD COLUMN adm_nr_district text; - -WITH overlay AS -(SELECT DISTINCT ON (c.aggregated_crossings_id) -- some of the admin areas are not clean/distinct, make sure to select just one - c.aggregated_crossings_id, - rd.admin_area_abbreviation as abms_regional_district, - muni.admin_area_abbreviation as abms_municipality, - ir.english_name as clab_indian_reserve_name, - ir.band_name as clab_indian_reserve_band_name, - np.english_name as clab_national_park_name, - pp.protected_lands_name as bc_protected_lands_name, - pmbc.owner_type as pmbc_owner_type, - nr.region_org_unit_name as adm_nr_region, - nr.district_name as adm_nr_district -FROM bcfishpass.crossings c -LEFT OUTER JOIN whse_legal_admin_boundaries.abms_regional_districts_sp rd -ON ST_Intersects(c.geom, rd.geom) -LEFT OUTER JOIN whse_legal_admin_boundaries.abms_municipalities_sp muni -ON ST_Intersects(c.geom, muni.geom) -LEFT OUTER JOIN whse_admin_boundaries.adm_indian_reserves_bands_sp ir -ON ST_Intersects(c.geom, ir.geom) -LEFT OUTER JOIN whse_admin_boundaries.clab_national_parks np -ON ST_Intersects(c.geom, np.geom) -LEFT OUTER JOIN whse_tantalis.ta_park_ecores_pa_svw pp -ON ST_Intersects(c.geom, pp.geom) -LEFT OUTER JOIN whse_cadastre.pmbc_parcel_fabric_poly_svw pmbc -ON ST_Intersects(c.geom, pmbc.geom) -LEFT OUTER JOIN whse_admin_boundaries.adm_nr_districts_sp nr -ON ST_Intersects(c.geom, pmbc.geom) -ORDER BY c.aggregated_crossings_id, rd.admin_area_abbreviation, muni.admin_area_abbreviation, ir.english_name, pp.protected_lands_name, pmbc.owner_type, nr.district_name) - -UPDATE bcfishpass.crossings c -SET - abms_regional_district = o.abms_regional_district, - abms_municipality = o.abms_municipality, - clab_indian_reserve_name = o.clab_indian_reserve_name, - clab_indian_reserve_band_name = o.clab_indian_reserve_band_name, - clab_national_park_name = o.clab_national_park_name, - bc_protected_lands_name = o.bc_protected_lands_name, - pmbc_owner_type = o.pmbc_owner_type, - adm_nr_region = o.adm_nr_region, - adm_nr_distric = o.adm_nr_district -FROM overlay o -WHERE c.aggregated_crossings_id = o.aggregated_crossings_id; \ No newline at end of file diff --git a/reports/crossings/sql/point_report.sql b/reports/crossings/sql/point_report.sql deleted file mode 100644 index 4876947b..00000000 --- a/reports/crossings/sql/point_report.sql +++ /dev/null @@ -1,662 +0,0 @@ --- --------------------------------- --- first, report on status at point --- --------------------------------- -WITH at_point AS -( - SELECT - a.:point_id, - coalesce(s.gradient, s2.gradient) as gradient, - s.barriers_bt_dnstr, - s.barriers_ch_cm_co_pk_sk_dnstr, - s.barriers_st_dnstr, - s.barriers_wct_dnstr - FROM bcfishpass.:point_table a - left outer join bcfishpass.streams s - ON a.linear_feature_id = s.linear_feature_id - AND a.downstream_route_measure > s.downstream_route_measure - .001 - AND a.downstream_route_measure + .001 < s.upstream_route_measure - AND a.watershed_group_code = s.watershed_group_code - INNER JOIN whse_basemapping.fwa_stream_networks_sp s2 - ON a.linear_feature_id = s2.linear_feature_id - AND a.downstream_route_measure > s2.downstream_route_measure - .001 - AND a.downstream_route_measure + .001 < s2.upstream_route_measure - AND a.watershed_group_code = s2.watershed_group_code - WHERE a.watershed_group_code = :'wsg' - --AND a.blue_line_key = a.watershed_key -- do not update points in side channels - ORDER BY a.:point_id -) - -UPDATE bcfishpass.:point_table p -SET - gradient = u.gradient, - barriers_bt_dnstr = u.barriers_bt_dnstr, - barriers_ch_cm_co_pk_sk_dnstr = u.barriers_ch_cm_co_pk_sk_dnstr, - barriers_st_dnstr = u.barriers_st_dnstr, - barriers_wct_dnstr = u.barriers_wct_dnstr -FROM at_point u -WHERE p.:point_id = u.:point_id; - - --- --------------------------------- --- next, report on upstream linear stats --- --------------------------------- -with upstr as materialized -( - select - a.:point_id, - s.linear_feature_id, - s.gradient, - s.edge_type, - s.waterbody_key, - s.barriers_bt_dnstr, - s.barriers_ch_cm_co_pk_sk_dnstr, - s.barriers_st_dnstr, - s.barriers_wct_dnstr, - s.model_spawning_ch, - s.model_spawning_co, - s.model_spawning_sk, - s.model_spawning_st, - s.model_spawning_wct, - s.model_spawning_bt, - s.model_spawning_cm, - s.model_spawning_pk, - s.model_rearing_ch, - s.model_rearing_co, - s.model_rearing_sk, - s.model_rearing_st, - s.model_rearing_wct, - s.model_rearing_bt, - s.geom - from bcfishpass.:point_table a - LEFT OUTER JOIN bcfishpass.streams s - ON FWA_Upstream( - a.blue_line_key, - a.downstream_route_measure, - a.wscode_ltree, - a.localcode_ltree, - s.blue_line_key, - s.downstream_route_measure, - s.wscode_ltree, - s.localcode_ltree, - True, - 1 - ) - where a.watershed_group_code = :'wsg' -), - -report AS -(SELECT - s.:point_id, - --- totals - COALESCE(ROUND((SUM(ST_Length(s.geom)::numeric) / 1000), 2), 0) AS total_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300)))) / 1000)::numeric, 2), 0) AS total_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS total_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS total_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .03 AND s.gradient < .05) / 1000))::numeric, 2), 0) as total_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .05 AND s.gradient < .08) / 1000))::numeric, 2), 0) as total_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .08 AND s.gradient < .15) / 1000))::numeric, 2), 0) as total_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .15 AND s.gradient < .22) / 1000))::numeric, 2), 0) as total_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .22 AND s.gradient < .30) / 1000))::numeric, 2), 0) as total_slopeclass30_km, - --- bull trout model - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS bt_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS bt_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_bt_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS bt_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_bt_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS bt_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as bt_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as bt_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as bt_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as bt_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_bt_dnstr = array[]::text[] AND (s.gradient >= .22 AND s.gradient < .3)) / 1000))::numeric, 2), 0) as bt_slopeclass30_km, - --- salmon model - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS ch_cm_co_pk_sk_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS ch_cm_co_pk_sk_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS ch_cm_co_pk_sk_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS ch_cm_co_pk_sk_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as ch_cm_co_pk_sk_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as ch_cm_co_pk_sk_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as ch_cm_co_pk_sk_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as ch_cm_co_pk_sk_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] AND (s.gradient >= .22 AND s.gradient < .3)) / 1000))::numeric, 2), 0) as ch_cm_co_pk_sk_slopeclass30_km, - --- steelhead - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS st_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS st_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_st_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS st_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_st_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS st_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as st_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as st_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as st_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as st_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_st_dnstr = array[]::text[] AND (s.gradient >= .22 AND s.gradient < .30)) / 1000))::numeric, 2), 0) as st_slopeclass30_km, - --- wct - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[]) / 1000)::numeric), 2), 0) AS wct_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS wct_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_wct_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS wct_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.barriers_wct_dnstr = array[]::text[]) AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS wct_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as wct_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as wct_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as wct_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as wct_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.barriers_wct_dnstr = array[]::text[] AND (s.gradient >= .22 AND s.gradient < .30)) / 1000))::numeric, 2), 0) as wct_slopeclass30_km, - --- habitat models - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_co IS TRUE) / 1000))::numeric, 2), 0) AS co_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_co IS TRUE) / 1000))::numeric, 2), 0) AS co_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_st IS TRUE) / 1000))::numeric, 2), 0) AS st_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_st IS TRUE) / 1000))::numeric, 2), 0) AS st_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_bt IS TRUE) / 1000))::numeric, 2), 0) AS bt_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_bt IS TRUE) / 1000))::numeric, 2), 0) AS bt_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_cm IS TRUE) / 1000))::numeric, 2), 0) AS cm_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_pk IS TRUE) / 1000))::numeric, 2), 0) AS pk_spawning_km , - - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_bt IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawning_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE OR - s.model_rearing_bt IS TRUE - ) / 1000))::numeric, 2), 0) AS all_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_bt IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE OR - s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE OR - s.model_rearing_bt IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawningrearing_km - -FROM upstr s -LEFT OUTER JOIN whse_basemapping.fwa_waterbodies wb ON s.waterbody_key = wb.waterbody_key -GROUP BY s.:point_id -) - -UPDATE bcfishpass.:point_table p -SET - total_network_km = r.total_network_km, - total_stream_km = r.total_stream_km, - total_slopeclass03_waterbodies_km = r.total_slopeclass03_waterbodies_km, - total_slopeclass03_km = r.total_slopeclass03_km, - total_slopeclass05_km = r.total_slopeclass05_km, - total_slopeclass08_km = r.total_slopeclass08_km, - total_slopeclass15_km = r.total_slopeclass15_km, - total_slopeclass22_km = r.total_slopeclass22_km, - total_slopeclass30_km = r.total_slopeclass30_km, - ch_cm_co_pk_sk_network_km = r.ch_cm_co_pk_sk_network_km, - ch_cm_co_pk_sk_stream_km = r.ch_cm_co_pk_sk_stream_km, - ch_cm_co_pk_sk_slopeclass03_waterbodies_km = r.ch_cm_co_pk_sk_slopeclass03_waterbodies_km, - ch_cm_co_pk_sk_slopeclass03_km = r.ch_cm_co_pk_sk_slopeclass03_km, - ch_cm_co_pk_sk_slopeclass05_km = r.ch_cm_co_pk_sk_slopeclass05_km, - ch_cm_co_pk_sk_slopeclass08_km = r.ch_cm_co_pk_sk_slopeclass08_km, - ch_cm_co_pk_sk_slopeclass15_km = r.ch_cm_co_pk_sk_slopeclass15_km, - ch_cm_co_pk_sk_slopeclass22_km = r.ch_cm_co_pk_sk_slopeclass22_km, - ch_cm_co_pk_sk_slopeclass30_km = r.ch_cm_co_pk_sk_slopeclass30_km, - st_network_km = r.st_network_km, - st_stream_km = r.st_stream_km, - st_slopeclass03_waterbodies_km = r.st_slopeclass03_waterbodies_km, - st_slopeclass03_km = r.st_slopeclass03_km, - st_slopeclass05_km = r.st_slopeclass05_km, - st_slopeclass08_km = r.st_slopeclass08_km, - st_slopeclass15_km = r.st_slopeclass15_km, - st_slopeclass22_km = r.st_slopeclass22_km, - st_slopeclass30_km = r.st_slopeclass30_km, - wct_network_km = r.wct_network_km, - wct_stream_km = r.wct_stream_km, - wct_slopeclass03_waterbodies_km = r.wct_slopeclass03_waterbodies_km, - wct_slopeclass03_km = r.wct_slopeclass03_km, - wct_slopeclass05_km = r.wct_slopeclass05_km, - wct_slopeclass08_km = r.wct_slopeclass08_km, - wct_slopeclass15_km = r.wct_slopeclass15_km, - wct_slopeclass22_km = r.wct_slopeclass22_km, - wct_slopeclass30_km = r.wct_slopeclass30_km, - bt_network_km = r.bt_network_km, - bt_stream_km = r.bt_stream_km, - bt_slopeclass03_waterbodies_km = r.bt_slopeclass03_waterbodies_km, - bt_slopeclass03_km = r.bt_slopeclass03_km, - bt_slopeclass05_km = r.bt_slopeclass05_km, - bt_slopeclass08_km = r.bt_slopeclass08_km, - bt_slopeclass15_km = r.bt_slopeclass15_km, - bt_slopeclass22_km = r.bt_slopeclass22_km, - bt_slopeclass30_km = r.bt_slopeclass30_km, - ch_spawning_km = r.ch_spawning_km, - ch_rearing_km = r.ch_rearing_km, - co_spawning_km = r.co_spawning_km, - co_rearing_km = r.co_rearing_km, - sk_spawning_km = r.sk_spawning_km, - sk_rearing_km = r.sk_rearing_km, - st_spawning_km = r.st_spawning_km, - st_rearing_km = r.st_rearing_km, - wct_spawning_km = r.wct_spawning_km, - wct_rearing_km = r.wct_rearing_km, - bt_spawning_km = r.bt_spawning_km, - bt_rearing_km = r.bt_rearing_km, - cm_spawning_km = r.cm_spawning_km, - - pk_spawning_km = r.pk_spawning_km, - - all_spawning_km = r.all_spawning_km, - all_rearing_km = r.all_rearing_km, - all_spawningrearing_km = r.all_spawningrearing_km -FROM report r -WHERE p.:point_id = r.:point_id -AND p.blue_line_key = p.watershed_key; -- do not update points in side channels - - --- increase linear total for co and sk rearing by 50% within wetlands/lakes --- this is just an attempt to give these more importance (as they aren't really linear anyway) -WITH lake_wetland_rearing AS -( - SELECT - a.:point_id, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_co IS TRUE AND wb.waterbody_type = 'W') / 1000))::numeric, 2), 0) AS co_rearing_km_wetland, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_sk IS TRUE AND wb.waterbody_type IN ('X','L')) / 1000))::numeric, 2), 0) AS sk_rearing_km_lake - FROM bcfishpass.:point_table a - LEFT OUTER JOIN bcfishpass.streams s - ON FWA_Upstream( - a.blue_line_key, - a.downstream_route_measure, - a.wscode_ltree, - a.localcode_ltree, - s.blue_line_key, - s.downstream_route_measure, - s.wscode_ltree, - s.localcode_ltree, - True, - 1 - ) - LEFT OUTER JOIN whse_basemapping.fwa_waterbodies wb - ON s.waterbody_key = wb.waterbody_key - WHERE a.watershed_group_code = :'wsg' - GROUP BY a.:point_id -) - -UPDATE bcfishpass.:point_table p -SET - co_rearing_km = co_rearing_km + (r.co_rearing_km_wetland * .5), - sk_rearing_km = sk_rearing_km + (r.sk_rearing_km_lake * .5), - all_rearing_km = all_rearing_km + (r.co_rearing_km_wetland * .5) + (r.sk_rearing_km_lake * .5), - all_spawningrearing_km = all_spawningrearing_km + (r.co_rearing_km_wetland * .5) + (r.sk_rearing_km_lake * .5) -FROM lake_wetland_rearing r -WHERE p.watershed_group_code = :'wsg' -AND p.:point_id = r.:point_id -AND p.blue_line_key = p.watershed_key; -- do not update points in side channels - - --- populate upstream area stats -WITH upstr_wb AS MATERIALIZED -- force this query to materialize so the wbkey filter does not get pushed down and ruin performance -(SELECT DISTINCT - a.:point_id, - s.waterbody_key, - s.barriers_ch_cm_co_pk_sk_dnstr, - s.barriers_st_dnstr, - s.barriers_wct_dnstr, - s.model_rearing_co, - s.model_rearing_sk, - ST_Area(lake.geom) as area_lake, - ST_Area(manmade.geom) as area_manmade, - ST_Area(wetland.geom) as area_wetland -FROM bcfishpass.:point_table a -LEFT OUTER JOIN bcfishpass.streams s -ON FWA_Upstream( - a.blue_line_key, - a.downstream_route_measure, - a.wscode_ltree, - a.localcode_ltree, - s.blue_line_key, - s.downstream_route_measure, - s.wscode_ltree, - s.localcode_ltree, - True, - 1 - ) -LEFT OUTER JOIN whse_basemapping.fwa_lakes_poly lake -ON s.waterbody_key = lake.waterbody_key -LEFT OUTER JOIN whse_basemapping.fwa_manmade_waterbodies_poly manmade -ON s.waterbody_key = manmade.waterbody_key -LEFT OUTER JOIN whse_basemapping.fwa_wetlands_poly wetland -ON s.waterbody_key = wetland.waterbody_key -WHERE a.watershed_group_code = :'wsg' -ORDER BY a.:point_id -), - -report AS -(SELECT - :point_id, - ROUND((( - SUM(COALESCE(uwb.area_lake, 0)) + SUM(COALESCE(uwb.area_manmade,0))) / 10000)::numeric, 2 - ) AS total_lakereservoir_ha, - ROUND((SUM(COALESCE(uwb.area_wetland, 0)) / 10000)::numeric, 2) AS total_wetland_ha, - ROUND(((SUM(COALESCE(uwb.area_lake, 0)) FILTER (WHERE uwb.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[]) + - SUM(COALESCE(uwb.area_manmade, 0)) FILTER (WHERE uwb.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[])) / 10000)::numeric, 2) AS ch_cm_co_pk_sk_lakereservoir_ha, - ROUND(((SUM(COALESCE(uwb.area_wetland, 0)) FILTER (WHERE uwb.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[])) / 10000)::numeric, 2) AS ch_cm_co_pk_sk_wetland_ha, - - ROUND(((SUM(COALESCE(uwb.area_lake, 0)) FILTER (WHERE uwb.barriers_st_dnstr = array[]::text[]) + - SUM(COALESCE(uwb.area_manmade, 0)) FILTER (WHERE uwb.barriers_st_dnstr = array[]::text[])) / 10000)::numeric, 2) AS st_lakereservoir_ha, - ROUND(((SUM(COALESCE(uwb.area_wetland, 0)) FILTER (WHERE uwb.barriers_st_dnstr = array[]::text[])) / 10000)::numeric, 2) AS st_wetland_ha, - ROUND(((SUM(COALESCE(uwb.area_lake, 0)) FILTER (WHERE uwb.barriers_wct_dnstr = array[]::text[]) + - SUM(COALESCE(uwb.area_manmade,0)) FILTER (WHERE uwb.barriers_wct_dnstr = array[]::text[])) / 10000)::numeric, 2) AS wct_lakereservoir_ha, - ROUND(((SUM(COALESCE(uwb.area_wetland, 0)) FILTER (WHERE uwb.barriers_wct_dnstr = array[]::text[])) / 10000)::numeric, 2) AS wct_wetland_ha, - ROUND(((SUM(COALESCE(uwb.area_wetland, 0)) FILTER (WHERE uwb.model_rearing_co = True)) / 10000)::numeric, 2) AS co_rearing_ha, - ROUND(((SUM(COALESCE(uwb.area_lake, 0)) FILTER (WHERE uwb.model_rearing_sk = True) + - SUM(COALESCE(uwb.area_manmade, 0)) FILTER (WHERE uwb.model_rearing_sk = True)) / 10000)::numeric, 2) AS sk_rearing_ha -FROM upstr_wb uwb -WHERE waterbody_key IS NOT NULL -GROUP BY :point_id -) - -UPDATE bcfishpass.:point_table p -SET - total_lakereservoir_ha = r.total_lakereservoir_ha, - total_wetland_ha = r.total_wetland_ha, - ch_cm_co_pk_sk_lakereservoir_ha = r.ch_cm_co_pk_sk_lakereservoir_ha, - ch_cm_co_pk_sk_wetland_ha = r.ch_cm_co_pk_sk_wetland_ha, - st_lakereservoir_ha = r.st_lakereservoir_ha, - st_wetland_ha = r.st_wetland_ha, - wct_lakereservoir_ha = r.wct_lakereservoir_ha, - wct_wetland_ha = r.wct_wetland_ha, - co_rearing_ha = r.co_rearing_ha, - sk_rearing_ha = r.sk_rearing_ha -FROM report r -WHERE p.:point_id = r.:point_id -AND p.blue_line_key = p.watershed_key; -- do not update points on side channels - - - --- Calculate and populate upstream length/area stats for below addtional upstream barriers --- (this is the total at the given point as already calculated, minus the total on all points immediately upstream of the point) --- NOTE - this has to be re-run separately for bcfishpass.crossings because it includes a mixture of passable/barriers, --- and not all tables we run this report on will have the barrier_status column --- see 00_report_crossings_obs_belowupstrbarriers.sql - --- default to total upstream -UPDATE bcfishpass.:point_table p -SET - total_belowupstrbarriers_network_km = total_network_km, - total_belowupstrbarriers_stream_km = total_stream_km, - total_belowupstrbarriers_lakereservoir_ha = total_lakereservoir_ha, - total_belowupstrbarriers_wetland_ha = total_wetland_ha, - total_belowupstrbarriers_slopeclass03_waterbodies_km = total_slopeclass03_waterbodies_km, - total_belowupstrbarriers_slopeclass03_km = total_slopeclass03_km, - total_belowupstrbarriers_slopeclass05_km = total_slopeclass05_km, - total_belowupstrbarriers_slopeclass08_km = total_slopeclass08_km, - total_belowupstrbarriers_slopeclass15_km = total_slopeclass15_km, - total_belowupstrbarriers_slopeclass22_km = total_slopeclass22_km, - total_belowupstrbarriers_slopeclass30_km = total_slopeclass30_km, - ch_cm_co_pk_sk_belowupstrbarriers_network_km = ch_cm_co_pk_sk_network_km, - ch_cm_co_pk_sk_belowupstrbarriers_stream_km = ch_cm_co_pk_sk_stream_km, - ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha = ch_cm_co_pk_sk_lakereservoir_ha, - ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha = ch_cm_co_pk_sk_wetland_ha, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km = ch_cm_co_pk_sk_slopeclass03_waterbodies_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km = ch_cm_co_pk_sk_slopeclass03_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km = ch_cm_co_pk_sk_slopeclass05_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km = ch_cm_co_pk_sk_slopeclass08_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km = ch_cm_co_pk_sk_slopeclass15_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km = ch_cm_co_pk_sk_slopeclass22_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km = ch_cm_co_pk_sk_slopeclass30_km, - - st_belowupstrbarriers_network_km = st_network_km, - st_belowupstrbarriers_stream_km = st_stream_km, - st_belowupstrbarriers_lakereservoir_ha = st_lakereservoir_ha, - st_belowupstrbarriers_wetland_ha = st_wetland_ha, - st_belowupstrbarriers_slopeclass03_km = st_slopeclass03_km, - st_belowupstrbarriers_slopeclass05_km = st_slopeclass05_km, - st_belowupstrbarriers_slopeclass08_km = st_slopeclass08_km, - st_belowupstrbarriers_slopeclass15_km = st_slopeclass15_km, - st_belowupstrbarriers_slopeclass22_km = st_slopeclass22_km, - st_belowupstrbarriers_slopeclass30_km = st_slopeclass30_km, - wct_belowupstrbarriers_network_km = wct_network_km, - wct_belowupstrbarriers_stream_km = wct_stream_km, - wct_belowupstrbarriers_lakereservoir_ha = wct_lakereservoir_ha, - wct_belowupstrbarriers_wetland_ha = wct_wetland_ha, - wct_belowupstrbarriers_slopeclass03_km = wct_slopeclass03_km, - wct_belowupstrbarriers_slopeclass05_km = wct_slopeclass05_km, - wct_belowupstrbarriers_slopeclass08_km = wct_slopeclass08_km, - wct_belowupstrbarriers_slopeclass15_km = wct_slopeclass15_km, - wct_belowupstrbarriers_slopeclass22_km = wct_slopeclass22_km, - wct_belowupstrbarriers_slopeclass30_km = wct_slopeclass30_km, - bt_belowupstrbarriers_network_km = bt_network_km, - bt_belowupstrbarriers_stream_km = bt_stream_km, - bt_belowupstrbarriers_lakereservoir_ha = bt_lakereservoir_ha, - bt_belowupstrbarriers_wetland_ha = bt_wetland_ha, - bt_belowupstrbarriers_slopeclass03_km = bt_slopeclass03_km, - bt_belowupstrbarriers_slopeclass05_km = bt_slopeclass05_km, - bt_belowupstrbarriers_slopeclass08_km = bt_slopeclass08_km, - bt_belowupstrbarriers_slopeclass15_km = bt_slopeclass15_km, - bt_belowupstrbarriers_slopeclass22_km = bt_slopeclass22_km, - bt_belowupstrbarriers_slopeclass30_km = bt_slopeclass30_km, - - ch_spawning_belowupstrbarriers_km = ch_spawning_km, - ch_rearing_belowupstrbarriers_km = ch_rearing_km, - co_spawning_belowupstrbarriers_km = co_spawning_km, - co_rearing_belowupstrbarriers_km = co_rearing_km, - sk_spawning_belowupstrbarriers_km = sk_spawning_km, - sk_rearing_belowupstrbarriers_km = sk_rearing_km, - st_spawning_belowupstrbarriers_km = st_spawning_km, - st_rearing_belowupstrbarriers_km = st_rearing_km, - wct_spawning_belowupstrbarriers_km = wct_spawning_km, - wct_rearing_belowupstrbarriers_km = wct_rearing_km, - bt_spawning_belowupstrbarriers_km = bt_spawning_km, - bt_rearing_belowupstrbarriers_km = bt_rearing_km, - cm_spawning_belowupstrbarriers_km = cm_spawning_km, - - pk_spawning_belowupstrbarriers_km = pk_spawning_km, - - all_spawning_belowupstrbarriers_km = all_spawning_km, - all_rearing_belowupstrbarriers_km = all_rearing_km, - all_spawningrearing_belowupstrbarriers_km = all_spawningrearing_km -WHERE watershed_group_code = :'wsg' -AND blue_line_key = watershed_key; -- do not include points in side channels - --- then calculate the rest where there is/are anthropogenic crossings upstream -WITH report AS -(SELECT - a.:point_id, - ROUND((COALESCE(a.total_network_km, 0) - SUM(COALESCE(b.total_network_km, 0)))::numeric, 2) total_belowupstrbarriers_network_km, - ROUND((COALESCE(a.total_stream_km, 0) - SUM(COALESCE(b.total_stream_km, 0)))::numeric, 2) total_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.total_lakereservoir_ha, 0) - SUM(COALESCE(b.total_lakereservoir_ha, 0)))::numeric, 2) total_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.total_wetland_ha, 0) - SUM(COALESCE(b.total_wetland_ha, 0)))::numeric, 2) total_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.total_slopeclass03_waterbodies_km, 0) - SUM(COALESCE(b.total_slopeclass03_waterbodies_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass03_waterbodies_km, - ROUND((COALESCE(a.total_slopeclass03_km, 0) - SUM(COALESCE(b.total_slopeclass03_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.total_slopeclass05_km, 0) - SUM(COALESCE(b.total_slopeclass05_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.total_slopeclass08_km, 0) - SUM(COALESCE(b.total_slopeclass08_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.total_slopeclass15_km, 0) - SUM(COALESCE(b.total_slopeclass15_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.total_slopeclass22_km, 0) - SUM(COALESCE(b.total_slopeclass22_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.total_slopeclass30_km, 0) - SUM(COALESCE(b.total_slopeclass30_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_network_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_network_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_network_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_stream_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_stream_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_lakereservoir_ha, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_lakereservoir_ha, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.ch_cm_co_pk_sk_wetland_ha, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_wetland_ha, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass03_waterbodies_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass03_waterbodies_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass03_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass03_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass05_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass05_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass08_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass08_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass15_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass15_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass22_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass22_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass30_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass30_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km, - - ROUND((COALESCE(a.st_network_km, 0) - SUM(COALESCE(b.st_network_km, 0)))::numeric, 2) st_belowupstrbarriers_network_km, - ROUND((COALESCE(a.st_stream_km, 0) - SUM(COALESCE(b.st_stream_km, 0)))::numeric, 2) st_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.st_lakereservoir_ha, 0) - SUM(COALESCE(b.st_lakereservoir_ha, 0)))::numeric, 2) st_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.st_wetland_ha, 0) - SUM(COALESCE(b.st_wetland_ha, 0)))::numeric, 2) st_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.st_slopeclass03_km, 0) - SUM(COALESCE(b.st_slopeclass03_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.st_slopeclass05_km, 0) - SUM(COALESCE(b.st_slopeclass05_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.st_slopeclass08_km, 0) - SUM(COALESCE(b.st_slopeclass08_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.st_slopeclass15_km, 0) - SUM(COALESCE(b.st_slopeclass15_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.st_slopeclass22_km, 0) - SUM(COALESCE(b.st_slopeclass22_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.st_slopeclass30_km, 0) - SUM(COALESCE(b.st_slopeclass30_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.wct_network_km, 0) - SUM(COALESCE(b.wct_network_km, 0)))::numeric, 2) wct_belowupstrbarriers_network_km, - ROUND((COALESCE(a.wct_stream_km, 0) - SUM(COALESCE(b.wct_stream_km, 0)))::numeric, 2) wct_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.wct_lakereservoir_ha, 0) - SUM(COALESCE(b.wct_lakereservoir_ha, 0)))::numeric, 2) wct_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.wct_wetland_ha, 0) - SUM(COALESCE(b.wct_wetland_ha, 0)))::numeric, 2) wct_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.wct_slopeclass03_km, 0) - SUM(COALESCE(b.wct_slopeclass03_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.wct_slopeclass05_km, 0) - SUM(COALESCE(b.wct_slopeclass05_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.wct_slopeclass08_km, 0) - SUM(COALESCE(b.wct_slopeclass08_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.wct_slopeclass15_km, 0) - SUM(COALESCE(b.wct_slopeclass15_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.wct_slopeclass22_km, 0) - SUM(COALESCE(b.wct_slopeclass22_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.wct_slopeclass30_km, 0) - SUM(COALESCE(b.wct_slopeclass30_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.ch_spawning_km, 0) - SUM(COALESCE(b.ch_spawning_km, 0)))::numeric, 2) ch_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.ch_rearing_km, 0) - SUM(COALESCE(b.ch_rearing_km, 0)))::numeric, 2) ch_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.co_spawning_km, 0) - SUM(COALESCE(b.co_spawning_km, 0)))::numeric, 2) co_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.co_rearing_km, 0) - SUM(COALESCE(b.co_rearing_km, 0)))::numeric, 2) co_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.co_rearing_ha, 0) - SUM(COALESCE(b.co_rearing_ha, 0)))::numeric, 2) co_rearing_belowupstrbarriers_ha, - ROUND((COALESCE(a.sk_spawning_km, 0) - SUM(COALESCE(b.sk_spawning_km, 0)))::numeric, 2) sk_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.sk_rearing_km, 0) - SUM(COALESCE(b.sk_rearing_km, 0)))::numeric, 2) sk_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.sk_rearing_ha, 0) - SUM(COALESCE(b.sk_rearing_ha, 0)))::numeric, 2) sk_rearing_belowupstrbarriers_ha , - ROUND((COALESCE(a.st_spawning_km, 0) - SUM(COALESCE(b.st_spawning_km, 0)))::numeric, 2) st_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.st_rearing_km, 0) - SUM(COALESCE(b.st_rearing_km, 0)))::numeric, 2) st_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.wct_spawning_km, 0) - SUM(COALESCE(b.wct_spawning_km, 0)))::numeric, 2) wct_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.wct_rearing_km, 0) - SUM(COALESCE(b.wct_rearing_km, 0)))::numeric, 2) wct_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.bt_spawning_km, 0) - SUM(COALESCE(b.bt_spawning_km, 0)))::numeric, 2) bt_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.bt_rearing_km, 0) - SUM(COALESCE(b.bt_rearing_km, 0)))::numeric, 2) bt_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.cm_spawning_km, 0) - SUM(COALESCE(b.cm_spawning_km, 0)))::numeric, 2) cm_spawning_belowupstrbarriers_km , - - ROUND((COALESCE(a.pk_spawning_km, 0) - SUM(COALESCE(b.pk_spawning_km, 0)))::numeric, 2) pk_spawning_belowupstrbarriers_km , - - ROUND((COALESCE(a.all_spawning_km, 0) - SUM(COALESCE(b.all_spawning_km, 0)))::numeric, 2) all_spawning_belowupstrbarriers_km, - ROUND((COALESCE(a.all_rearing_km, 0) - SUM(COALESCE(b.all_rearing_km, 0)))::numeric, 2) all_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.all_spawningrearing_km, 0) - SUM(COALESCE(b.all_spawningrearing_km, 0)))::numeric, 2) all_spawningrearing_belowupstrbarriers_km -FROM bcfishpass.:point_table a -INNER JOIN bcfishpass.:barriers_table b -ON a.:point_id = b.:dnstr_barriers_id[1] -WHERE - a.watershed_group_code = :'wsg' -GROUP BY a.:point_id -) - -UPDATE bcfishpass.:point_table p -SET - total_belowupstrbarriers_network_km = r.total_belowupstrbarriers_network_km, - total_belowupstrbarriers_stream_km = r.total_belowupstrbarriers_stream_km, - total_belowupstrbarriers_lakereservoir_ha = r.total_belowupstrbarriers_lakereservoir_ha, - total_belowupstrbarriers_wetland_ha = r.total_belowupstrbarriers_wetland_ha, - total_belowupstrbarriers_slopeclass03_waterbodies_km = r.total_belowupstrbarriers_slopeclass03_waterbodies_km, - total_belowupstrbarriers_slopeclass03_km = r.total_belowupstrbarriers_slopeclass03_km, - total_belowupstrbarriers_slopeclass05_km = r.total_belowupstrbarriers_slopeclass05_km, - total_belowupstrbarriers_slopeclass08_km = r.total_belowupstrbarriers_slopeclass08_km, - total_belowupstrbarriers_slopeclass15_km = r.total_belowupstrbarriers_slopeclass15_km, - total_belowupstrbarriers_slopeclass22_km = r.total_belowupstrbarriers_slopeclass22_km, - total_belowupstrbarriers_slopeclass30_km = r.total_belowupstrbarriers_slopeclass30_km, - ch_cm_co_pk_sk_belowupstrbarriers_network_km = r.ch_cm_co_pk_sk_belowupstrbarriers_network_km, - ch_cm_co_pk_sk_belowupstrbarriers_stream_km = r.ch_cm_co_pk_sk_belowupstrbarriers_stream_km, - ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha = r.ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha, - ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha = r.ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km, - - st_belowupstrbarriers_network_km = r.st_belowupstrbarriers_network_km, - st_belowupstrbarriers_stream_km = r.st_belowupstrbarriers_stream_km, - st_belowupstrbarriers_lakereservoir_ha = r.st_belowupstrbarriers_lakereservoir_ha, - st_belowupstrbarriers_wetland_ha = r.st_belowupstrbarriers_wetland_ha, - st_belowupstrbarriers_slopeclass03_km = r.st_belowupstrbarriers_slopeclass03_km, - st_belowupstrbarriers_slopeclass05_km = r.st_belowupstrbarriers_slopeclass05_km, - st_belowupstrbarriers_slopeclass08_km = r.st_belowupstrbarriers_slopeclass08_km, - st_belowupstrbarriers_slopeclass15_km = r.st_belowupstrbarriers_slopeclass15_km, - st_belowupstrbarriers_slopeclass22_km = r.st_belowupstrbarriers_slopeclass22_km, - st_belowupstrbarriers_slopeclass30_km = r.st_belowupstrbarriers_slopeclass30_km, - - wct_belowupstrbarriers_network_km = r.wct_belowupstrbarriers_network_km, - wct_belowupstrbarriers_stream_km = r.wct_belowupstrbarriers_stream_km, - wct_belowupstrbarriers_lakereservoir_ha = r.wct_belowupstrbarriers_lakereservoir_ha, - wct_belowupstrbarriers_wetland_ha = r.wct_belowupstrbarriers_wetland_ha, - wct_belowupstrbarriers_slopeclass03_km = r.wct_belowupstrbarriers_slopeclass03_km, - wct_belowupstrbarriers_slopeclass05_km = r.wct_belowupstrbarriers_slopeclass05_km, - wct_belowupstrbarriers_slopeclass08_km = r.wct_belowupstrbarriers_slopeclass08_km, - wct_belowupstrbarriers_slopeclass15_km = r.wct_belowupstrbarriers_slopeclass15_km, - wct_belowupstrbarriers_slopeclass22_km = r.wct_belowupstrbarriers_slopeclass22_km, - wct_belowupstrbarriers_slopeclass30_km = r.wct_belowupstrbarriers_slopeclass30_km, - - ch_spawning_belowupstrbarriers_km = r.ch_spawning_belowupstrbarriers_km, - ch_rearing_belowupstrbarriers_km = r.ch_rearing_belowupstrbarriers_km, - co_spawning_belowupstrbarriers_km = r.co_spawning_belowupstrbarriers_km, - co_rearing_belowupstrbarriers_km = r.co_rearing_belowupstrbarriers_km, - sk_spawning_belowupstrbarriers_km = r.sk_spawning_belowupstrbarriers_km, - sk_rearing_belowupstrbarriers_km = r.sk_rearing_belowupstrbarriers_km, - st_spawning_belowupstrbarriers_km = r.st_spawning_belowupstrbarriers_km, - st_rearing_belowupstrbarriers_km = r.st_rearing_belowupstrbarriers_km, - wct_spawning_belowupstrbarriers_km = r.wct_spawning_belowupstrbarriers_km, - wct_rearing_belowupstrbarriers_km = r.wct_rearing_belowupstrbarriers_km, - bt_spawning_belowupstrbarriers_km = r.bt_spawning_belowupstrbarriers_km, - bt_rearing_belowupstrbarriers_km = r.bt_rearing_belowupstrbarriers_km, - pk_spawning_belowupstrbarriers_km = r.pk_spawning_belowupstrbarriers_km, - cm_spawning_belowupstrbarriers_km = r.cm_spawning_belowupstrbarriers_km, - all_spawning_belowupstrbarriers_km = r.all_spawning_belowupstrbarriers_km, - all_rearing_belowupstrbarriers_km = r.all_rearing_belowupstrbarriers_km, - all_spawningrearing_belowupstrbarriers_km = r.all_spawningrearing_belowupstrbarriers_km -FROM report r -WHERE p.:point_id = r.:point_id -AND p.blue_line_key = p.watershed_key; -- do not update points in side channels - --- ELK River WCT specific reporting, but run it everywhere -UPDATE bcfishpass.:point_table p -SET wct_betweenbarriers_network_km = ROUND((p.wct_belowupstrbarriers_network_km + b.wct_belowupstrbarriers_network_km)::numeric, 2), - wct_spawning_betweenbarriers_km = ROUND((p.wct_spawning_belowupstrbarriers_km + b.wct_spawning_belowupstrbarriers_km)::numeric, 2), - wct_rearing_betweenbarriers_km = ROUND((p.wct_rearing_belowupstrbarriers_km + b.wct_rearing_belowupstrbarriers_km)::numeric, 2), - wct_spawningrearing_betweenbarriers_km = ROUND((p.all_spawningrearing_belowupstrbarriers_km + b.all_spawningrearing_belowupstrbarriers_km)::numeric, 2) -FROM bcfishpass.:point_table b -WHERE - p.:dnstr_barriers_id[1] = b.:point_id AND - p.wct_network_km != 0 AND - p.watershed_group_code = :'wsg' AND - p.blue_line_key = p.watershed_key; - --- separate update for where there are no barriers downstream -UPDATE bcfishpass.:point_table -SET wct_betweenbarriers_network_km = wct_belowupstrbarriers_network_km, - wct_spawning_betweenbarriers_km = wct_spawning_belowupstrbarriers_km, - wct_rearing_betweenbarriers_km = wct_rearing_belowupstrbarriers_km, - wct_spawningrearing_betweenbarriers_km = all_spawningrearing_belowupstrbarriers_km -WHERE - :dnstr_barriers_id IS NULL AND - wct_network_km != 0 AND - watershed_group_code = :'wsg' AND - blue_line_key = watershed_key; \ No newline at end of file diff --git a/reports/crossings/sql/point_report_columns.sql b/reports/crossings/sql/point_report_columns.sql deleted file mode 100644 index 5003943d..00000000 --- a/reports/crossings/sql/point_report_columns.sql +++ /dev/null @@ -1,341 +0,0 @@ --- -------------------- --- ADD REQUIRED COLUMNS TO EXISTING TABLE --- -------------------- - -ALTER TABLE bcfishpass.:point_table - ADD COLUMN IF NOT EXISTS gradient double precision, - ADD COLUMN IF NOT EXISTS total_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_slopeclass30_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS total_belowupstrbarriers_slopeclass30_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS barriers_bt_dnstr text[], - ADD COLUMN IF NOT EXISTS bt_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_slopeclass30_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_belowupstrbarriers_slopeclass30_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS barriers_ch_cm_co_pk_sk_dnstr text[], - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_slopeclass30_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS barriers_st_dnstr text[], - ADD COLUMN IF NOT EXISTS st_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_slopeclass30_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_belowupstrbarriers_slopeclass30_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS barriers_wct_dnstr text[], - ADD COLUMN IF NOT EXISTS wct_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_slopeclass30_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_stream_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_lakereservoir_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_wetland_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass03_waterbodies_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass03_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass05_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass08_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass15_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass22_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_belowupstrbarriers_slopeclass30_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS bt_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS bt_rearing_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS ch_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS ch_rearing_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS cm_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS cm_spawning_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS co_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS co_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS co_rearing_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS co_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS co_rearing_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS co_rearing_belowupstrbarriers_ha double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS pk_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS pk_spawning_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS sk_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS sk_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS sk_rearing_ha double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS sk_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS sk_rearing_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS sk_rearing_belowupstrbarriers_ha double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS st_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS st_rearing_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS wct_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_rearing_belowupstrbarriers_km double precision DEFAULT 0, - - ADD COLUMN IF NOT EXISTS all_spawning_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS all_spawning_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS all_rearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS all_rearing_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS all_spawningrearing_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS all_spawningrearing_belowupstrbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_betweenbarriers_network_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_spawning_betweenbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_rearing_betweenbarriers_km double precision DEFAULT 0, - ADD COLUMN IF NOT EXISTS wct_spawningrearing_betweenbarriers_km double precision DEFAULT 0; - - - --- -------------------- --- ADD COMMENTS TO THE NEW COLUMNS --- -------------------- -COMMENT ON COLUMN bcfishpass.:point_table.gradient IS 'Stream slope at point'; -COMMENT ON COLUMN bcfishpass.:point_table.total_network_km IS 'Total length of stream network upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.total_stream_km IS 'Total length of streams and rivers upstream of point (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.total_lakereservoir_ha IS 'Total area lakes and reservoirs upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.total_wetland_ha IS 'Total area wetlands upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass03_waterbodies_km IS 'Total length of stream connectors (in waterbodies) potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass03_km IS 'Total length of stream potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass05_km IS 'Total length of stream potentially accessible upstream of point with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass08_km IS 'Total length of stream potentially accessible upstream of point with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass15_km IS 'Total length of stream potentially accessible upstream of point with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass22_km IS 'Total length of stream potentially accessible upstream of point with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_slopeclass30_km IS 'Total length of stream potentially accessible upstream of point with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_network_km IS 'Total length of stream network potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_stream_km IS 'Total length of streams and rivers potentially accessible upstream of point and below any additional upstream barriers (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_lakereservoir_ha IS 'Total area lakes and reservoirs potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_wetland_ha IS 'Total area wetlands potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass03_waterbodies_km IS 'Total length of stream connectors (in waterbodies) potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass03_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass05_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass08_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass15_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass22_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.total_belowupstrbarriers_slopeclass30_km IS 'Total length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 22-30%'; - -COMMENT ON COLUMN bcfishpass.:point_table.barriers_bt_dnstr IS 'Modelled accessibility to Bull Trout (25% max)'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_network_km IS 'Bull Trout model, total length of stream network potentially accessible upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_stream_km IS 'Bull Trout model, total length of streams and rivers potentially accessible upstream of point (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_lakereservoir_ha IS 'Bull Trout model, total area lakes and reservoirs potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.bt_wetland_ha IS 'Bull Trout model, total area wetlands potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass03_waterbodies_km IS 'Bull Trout model, length of stream connectors (in waterbodies) potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass03_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass05_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass08_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass15_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass22_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_slopeclass30_km IS 'Bull Trout model, length of stream potentially accessible upstream of point with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_network_km IS 'Bull Trout model, total length of stream network potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_stream_km IS 'Bull Trout model, total length of streams and rivers potentially accessible upstream of point and below any additional upstream barriers (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_lakereservoir_ha IS 'Bull Trout model, total area lakes and reservoirs potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_wetland_ha IS 'Bull Trout model, total area wetlands potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass03_waterbodies_km IS 'Bull Trout model, length of stream connectors (in waterbodies) potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass03_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass05_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass08_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass15_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass22_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_belowupstrbarriers_slopeclass30_km IS 'Bull Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 22-30%'; - -COMMENT ON COLUMN bcfishpass.:point_table.barriers_ch_cm_co_pk_sk_dnstr IS 'Modelled accessibility to Pacific Salmon (CH/CM/CO/PK/SK, 15% max)'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_network_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), total length of stream network potentially accessible upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_stream_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), total length of streams and rivers potentially accessible upstream of point (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_lakereservoir_ha IS 'Pacific salmon model (CH/CM/CO/PK/SK), total area lakes and reservoirs potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_wetland_ha IS 'Pacific salmon model (CH/CM/CO/PK/SK), total area wetlands potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass03_waterbodies_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream connectors (in waterbodies) potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass03_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass05_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass08_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass15_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass22_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_slopeclass30_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_network_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), total length of stream network potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_stream_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), total length of streams and rivers potentially accessible upstream of point and below any additional upstream barriers (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha IS 'Pacific salmon model (CH/CM/CO/PK/SK), total area lakes and reservoirs potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha IS 'Pacific salmon model (CH/CM/CO/PK/SK), total area wetlands potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream connectors (in waterbodies) potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km IS 'Pacific salmon model (CH/CM/CO/PK/SK), length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 22-30%'; - -COMMENT ON COLUMN bcfishpass.:point_table.barriers_st_dnstr IS 'Modelled accessibility to Steelhead (20% max)'; -COMMENT ON COLUMN bcfishpass.:point_table.st_network_km IS 'Steelhead model, total length of stream network potentially accessible upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.st_stream_km IS 'Steelhead model, total length of streams and rivers potentially accessible upstream of point (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.st_lakereservoir_ha IS 'Steelhead model, total area lakes and reservoirs potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.st_wetland_ha IS 'Steelhead model, total area wetlands potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass03_waterbodies_km IS 'Steelhead model, length of stream connectors (in waterbodies) potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass03_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass05_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass08_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass15_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass22_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_slopeclass30_km IS 'Steelhead model, length of stream potentially accessible upstream of point with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_network_km IS 'Steelhead model, total length of stream network potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_stream_km IS 'Steelhead model, total length of streams and rivers potentially accessible upstream of point and below any additional upstream barriers (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_lakereservoir_ha IS 'Steelhead model, total area lakes and reservoirs potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_wetland_ha IS 'Steelhead model, total area wetlands potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass03_waterbodies_km IS 'Steelhead model, length of stream connectors (in waterbodies) potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass03_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass05_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass08_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass15_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass22_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.st_belowupstrbarriers_slopeclass30_km IS 'Steelhead model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.barriers_wct_dnstr IS 'Modelled accessibility to West Slope Cutthroat Trout (20% max or downstream of known WCT observation)'; ; -COMMENT ON COLUMN bcfishpass.:point_table.wct_network_km IS 'Westslope Cuthroat Trout model, total length of stream network potentially accessible upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_stream_km IS 'Westslope Cuthroat Trout model, total length of streams and rivers potentially accessible upstream of point (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_lakereservoir_ha IS 'Westslope Cuthroat Trout model, total area lakes and reservoirs potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.wct_wetland_ha IS 'Westslope Cuthroat Trout model, total area wetlands potentially accessible upstream of point '; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass03_waterbodies_km IS 'Westslope Cutthroat Trout model, length of stream connectors (in waterbodies) potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass03_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass05_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass08_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass15_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass22_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_slopeclass30_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point with slope 22-30%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_network_km IS 'Westslope Cutthroat Trout model, total length of stream network potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_stream_km IS 'Westslope Cuthroat Trout model, total length of streams and rivers potentially accessible upstream of point and below any additional upstream barriers (does not include network connectors in lakes etc)'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_lakereservoir_ha IS 'Westslope Cutthroat Trout model, total area lakes and reservoirs potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_wetland_ha IS 'Westslope Cutthroat Trout model, total area wetlands potentially accessible upstream of point and below any additional upstream barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass03_waterbodies_km IS 'Westslope Cutthroat Trout model, length of stream connectors (in waterbodies) potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass03_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 0-3%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass05_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 3-5%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass08_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 5-8%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass15_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 8-15%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass22_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 15-22%'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_belowupstrbarriers_slopeclass30_km IS 'Westslope Cutthroat Trout model, length of stream potentially accessible upstream of point and below any additional upstream barriers, with slope 22-30%'; - -COMMENT ON COLUMN bcfishpass.:point_table.ch_spawning_km IS 'Length of stream upstream of point modelled as potential Chinook spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_rearing_km IS 'Length of stream upstream of point modelled as potential Chinook rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Chinook spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.ch_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Chinook rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_spawning_km IS 'Length of stream upstream of point modelled as potential Coho spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_rearing_km IS 'Length of stream upstream of point modelled as potential Coho rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_rearing_ha IS 'Area of wetlands upstream of point modelled as potential Coho rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Coho spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Coho rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.co_rearing_belowupstrbarriers_ha IS 'Area of wetlands upstream of point and below any additional upstream barriers, modelled as potential Coho rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_spawning_km IS 'Length of stream upstream of point modelled as potential Sockeye spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_rearing_km IS 'Length of stream upstream of point modelled as potential Sockeye rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_rearing_ha IS 'Area of lakes upstream of point modelled as potential Sockeye rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Sockeye spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Sockeye rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.sk_rearing_belowupstrbarriers_ha IS 'Area of lakes upstream of point and below any additional upstream barriers, modelled as potential Sockeye rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.st_spawning_km IS 'Length of stream upstream of point modelled as potential Steelhead spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.st_rearing_km IS 'Length of stream upstream of point modelled as potential Steelhead rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.st_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Steelhead spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.st_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Steelhead rearing habitat'; - -COMMENT ON COLUMN bcfishpass.:point_table.wct_spawning_km IS 'Length of stream upstream of point modelled as potential Westslope Cutthroat spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_rearing_km IS 'Length of stream upstream of point modelled as potential Westslope Cutthroat rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Westslope Cutthroat spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Westslope Cutthroat rearing habitat'; - -COMMENT ON COLUMN bcfishpass.:point_table.bt_spawning_km IS 'Length of stream upstream of point modelled as potential Bull Trout spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_rearing_km IS 'Length of stream upstream of point modelled as potential Bull Trout rearing habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Bull Trout spawning habitat'; -COMMENT ON COLUMN bcfishpass.:point_table.bt_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential Bull Trout rearing habitat'; - -COMMENT ON COLUMN bcfishpass.:point_table.all_spawning_km IS 'Length of stream upstream of point modelled as potential spawning habitat for all modelled species (currently BT,CH,CO,SK,ST,WCT)'; -COMMENT ON COLUMN bcfishpass.:point_table.all_spawning_belowupstrbarriers_km IS 'Length of stream upstream of point modelled as potential rearing habitat for all modelled species (currently BT,CH,CO,SK,ST,WCT)'; -COMMENT ON COLUMN bcfishpass.:point_table.all_rearing_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential spawning habitat for all modelled species (currently BT,CH,CO,SK,ST,WCT)'; -COMMENT ON COLUMN bcfishpass.:point_table.all_rearing_belowupstrbarriers_km IS 'Length of stream upstream of point and below any additional upstream barriers, modelled as potential rearing habitat (all CH,CO,SK,ST,WCT)'; -COMMENT ON COLUMN bcfishpass.:point_table.all_spawningrearing_km IS 'Length of all spawning and rearing habitat upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.all_spawningrearing_belowupstrbarriers_km IS 'Length of all spawning and rearing habitat upstream of point'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_betweenbarriers_network_km IS 'Westslope Cutthroat Trout model, total length of potentially accessible stream network between crossing and all in-stream adjacent barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_spawning_betweenbarriers_km IS 'Westslope Cutthroat Trout model, total length of spawning habitat between crossing and all in-stream adjacent barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_rearing_betweenbarriers_km IS 'Westslope Cutthroat Trout model, total length of rearing habitat between crossing and all in-stream adjacent barriers'; -COMMENT ON COLUMN bcfishpass.:point_table.wct_spawningrearing_betweenbarriers_km IS 'Westslope Cutthroat Trout model, total length of spawning and rearing habitat between crossing and all in-stream adjacent barriers'; diff --git a/reports/crossings/sql/point_report_obs_belowupstrbarriers.sql b/reports/crossings/sql/point_report_obs_belowupstrbarriers.sql deleted file mode 100644 index bcf43bb8..00000000 --- a/reports/crossings/sql/point_report_obs_belowupstrbarriers.sql +++ /dev/null @@ -1,132 +0,0 @@ --- for crossings, report on belowupstrbarriers categories is a bit different because the table has a mix of barriers/non-barriers --- run it separately here. -WITH report AS -(SELECT - a.aggregated_crossings_id, - ROUND((COALESCE(a.total_network_km, 0) - SUM(COALESCE(b.total_network_km, 0)))::numeric, 2) total_belowupstrbarriers_network_km, - ROUND((COALESCE(a.total_stream_km, 0) - SUM(COALESCE(b.total_stream_km, 0)))::numeric, 2) total_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.total_lakereservoir_ha, 0) - SUM(COALESCE(b.total_lakereservoir_ha, 0)))::numeric, 2) total_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.total_wetland_ha, 0) - SUM(COALESCE(b.total_wetland_ha, 0)))::numeric, 2) total_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.total_slopeclass03_waterbodies_km, 0) - SUM(COALESCE(b.total_slopeclass03_waterbodies_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass03_waterbodies_km, - ROUND((COALESCE(a.total_slopeclass03_km, 0) - SUM(COALESCE(b.total_slopeclass03_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.total_slopeclass05_km, 0) - SUM(COALESCE(b.total_slopeclass05_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.total_slopeclass08_km, 0) - SUM(COALESCE(b.total_slopeclass08_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.total_slopeclass15_km, 0) - SUM(COALESCE(b.total_slopeclass15_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.total_slopeclass22_km, 0) - SUM(COALESCE(b.total_slopeclass22_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.total_slopeclass30_km, 0) - SUM(COALESCE(b.total_slopeclass30_km, 0)))::numeric, 2) total_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_network_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_network_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_network_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_stream_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_stream_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_lakereservoir_ha, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_lakereservoir_ha, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.ch_cm_co_pk_sk_wetland_ha, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_wetland_ha, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass03_waterbodies_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass03_waterbodies_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass03_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass03_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass05_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass05_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass08_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass08_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass15_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass15_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass22_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass22_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.ch_cm_co_pk_sk_slopeclass30_km, 0) - SUM(COALESCE(b.ch_cm_co_pk_sk_slopeclass30_km, 0)))::numeric, 2) ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.st_network_km, 0) - SUM(COALESCE(b.st_network_km, 0)))::numeric, 2) st_belowupstrbarriers_network_km, - ROUND((COALESCE(a.st_stream_km, 0) - SUM(COALESCE(b.st_stream_km, 0)))::numeric, 2) st_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.st_lakereservoir_ha, 0) - SUM(COALESCE(b.st_lakereservoir_ha, 0)))::numeric, 2) st_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.st_wetland_ha, 0) - SUM(COALESCE(b.st_wetland_ha, 0)))::numeric, 2) st_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.st_slopeclass03_km, 0) - SUM(COALESCE(b.st_slopeclass03_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.st_slopeclass05_km, 0) - SUM(COALESCE(b.st_slopeclass05_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.st_slopeclass08_km, 0) - SUM(COALESCE(b.st_slopeclass08_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.st_slopeclass15_km, 0) - SUM(COALESCE(b.st_slopeclass15_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.st_slopeclass22_km, 0) - SUM(COALESCE(b.st_slopeclass22_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.st_slopeclass30_km, 0) - SUM(COALESCE(b.st_slopeclass30_km, 0)))::numeric, 2) st_belowupstrbarriers_slopeclass30_km, - ROUND((COALESCE(a.wct_network_km, 0) - SUM(COALESCE(b.wct_network_km, 0)))::numeric, 2) wct_belowupstrbarriers_network_km, - ROUND((COALESCE(a.wct_stream_km, 0) - SUM(COALESCE(b.wct_stream_km, 0)))::numeric, 2) wct_belowupstrbarriers_stream_km, - ROUND((COALESCE(a.wct_lakereservoir_ha, 0) - SUM(COALESCE(b.wct_lakereservoir_ha, 0)))::numeric, 2) wct_belowupstrbarriers_lakereservoir_ha, - ROUND((COALESCE(a.wct_wetland_ha, 0) - SUM(COALESCE(b.wct_wetland_ha, 0)))::numeric, 2) wct_belowupstrbarriers_wetland_ha, - ROUND((COALESCE(a.wct_slopeclass03_km, 0) - SUM(COALESCE(b.wct_slopeclass03_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass03_km, - ROUND((COALESCE(a.wct_slopeclass05_km, 0) - SUM(COALESCE(b.wct_slopeclass05_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass05_km, - ROUND((COALESCE(a.wct_slopeclass08_km, 0) - SUM(COALESCE(b.wct_slopeclass08_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass08_km, - ROUND((COALESCE(a.wct_slopeclass15_km, 0) - SUM(COALESCE(b.wct_slopeclass15_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass15_km, - ROUND((COALESCE(a.wct_slopeclass22_km, 0) - SUM(COALESCE(b.wct_slopeclass22_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass22_km, - ROUND((COALESCE(a.wct_slopeclass30_km, 0) - SUM(COALESCE(b.wct_slopeclass30_km, 0)))::numeric, 2) wct_belowupstrbarriers_slopeclass30_km, - - ROUND((COALESCE(a.ch_spawning_km, 0) - SUM(COALESCE(b.ch_spawning_km, 0)))::numeric, 2) ch_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.ch_rearing_km, 0) - SUM(COALESCE(b.ch_rearing_km, 0)))::numeric, 2) ch_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.co_spawning_km, 0) - SUM(COALESCE(b.co_spawning_km, 0)))::numeric, 2) co_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.co_rearing_km, 0) - SUM(COALESCE(b.co_rearing_km, 0)))::numeric, 2) co_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.co_rearing_ha, 0) - SUM(COALESCE(b.co_rearing_ha, 0)))::numeric, 2) co_rearing_belowupstrbarriers_ha , - ROUND((COALESCE(a.sk_spawning_km, 0) - SUM(COALESCE(b.sk_spawning_km, 0)))::numeric, 2) sk_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.sk_rearing_km, 0) - SUM(COALESCE(b.sk_rearing_km, 0)))::numeric, 2) sk_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.sk_rearing_ha, 0) - SUM(COALESCE(b.sk_rearing_km, 0)))::numeric, 2) sk_rearing_belowupstrbarriers_ha , - ROUND((COALESCE(a.st_spawning_km, 0) - SUM(COALESCE(b.st_spawning_km, 0)))::numeric, 2) st_spawning_belowupstrbarriers_km , - ROUND((COALESCE(a.st_rearing_km, 0) - SUM(COALESCE(b.st_rearing_km, 0)))::numeric, 2) st_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.all_spawning_km, 0) - SUM(COALESCE(b.all_spawning_km, 0)))::numeric, 2) all_spawning_belowupstrbarriers_km, - ROUND((COALESCE(a.all_rearing_km, 0) - SUM(COALESCE(b.all_rearing_km, 0)))::numeric, 2) all_rearing_belowupstrbarriers_km , - ROUND((COALESCE(a.all_spawningrearing_km, 0) - SUM(COALESCE(b.all_spawningrearing_km, 0)))::numeric, 2) all_spawningrearing_belowupstrbarriers_km - -FROM bcfishpass.crossings a -INNER JOIN bcfishpass.crossings b -ON a.aggregated_crossings_id = b.crossings_dnstr[1] -WHERE - b.barrier_status IN ('BARRIER', 'POTENTIAL') AND - a.barrier_status = 'PASSABLE' AND - a.blue_line_key = a.watershed_key -GROUP BY a.aggregated_crossings_id -) - -UPDATE bcfishpass.crossings p -SET - total_belowupstrbarriers_network_km = r.total_belowupstrbarriers_network_km, - total_belowupstrbarriers_stream_km = r.total_belowupstrbarriers_stream_km, - total_belowupstrbarriers_lakereservoir_ha = r.total_belowupstrbarriers_lakereservoir_ha, - total_belowupstrbarriers_wetland_ha = r.total_belowupstrbarriers_wetland_ha, - total_belowupstrbarriers_slopeclass03_waterbodies_km = r.total_belowupstrbarriers_slopeclass03_waterbodies_km, - total_belowupstrbarriers_slopeclass03_km = r.total_belowupstrbarriers_slopeclass03_km, - total_belowupstrbarriers_slopeclass05_km = r.total_belowupstrbarriers_slopeclass05_km, - total_belowupstrbarriers_slopeclass08_km = r.total_belowupstrbarriers_slopeclass08_km, - total_belowupstrbarriers_slopeclass15_km = r.total_belowupstrbarriers_slopeclass15_km, - total_belowupstrbarriers_slopeclass22_km = r.total_belowupstrbarriers_slopeclass22_km, - total_belowupstrbarriers_slopeclass30_km = r.total_belowupstrbarriers_slopeclass30_km, - ch_cm_co_pk_sk_belowupstrbarriers_network_km = r.ch_cm_co_pk_sk_belowupstrbarriers_network_km, - ch_cm_co_pk_sk_belowupstrbarriers_stream_km = r.ch_cm_co_pk_sk_belowupstrbarriers_stream_km, - ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha = r.ch_cm_co_pk_sk_belowupstrbarriers_lakereservoir_ha, - ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha = r.ch_cm_co_pk_sk_belowupstrbarriers_wetland_ha, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_waterbodies_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass03_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass05_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass08_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass15_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass22_km, - ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km = r.ch_cm_co_pk_sk_belowupstrbarriers_slopeclass30_km, - st_belowupstrbarriers_network_km = r.st_belowupstrbarriers_network_km, - st_belowupstrbarriers_stream_km = r.st_belowupstrbarriers_stream_km, - st_belowupstrbarriers_lakereservoir_ha = r.st_belowupstrbarriers_lakereservoir_ha, - st_belowupstrbarriers_wetland_ha = r.st_belowupstrbarriers_wetland_ha, - st_belowupstrbarriers_slopeclass03_km = r.st_belowupstrbarriers_slopeclass03_km, - st_belowupstrbarriers_slopeclass05_km = r.st_belowupstrbarriers_slopeclass05_km, - st_belowupstrbarriers_slopeclass08_km = r.st_belowupstrbarriers_slopeclass08_km, - st_belowupstrbarriers_slopeclass15_km = r.st_belowupstrbarriers_slopeclass15_km, - st_belowupstrbarriers_slopeclass22_km = r.st_belowupstrbarriers_slopeclass22_km, - st_belowupstrbarriers_slopeclass30_km = r.st_belowupstrbarriers_slopeclass30_km, - wct_belowupstrbarriers_network_km = r.wct_belowupstrbarriers_network_km, - wct_belowupstrbarriers_stream_km = r.wct_belowupstrbarriers_stream_km, - wct_belowupstrbarriers_lakereservoir_ha = r.wct_belowupstrbarriers_lakereservoir_ha, - wct_belowupstrbarriers_wetland_ha = r.wct_belowupstrbarriers_wetland_ha, - wct_belowupstrbarriers_slopeclass03_km = r.wct_belowupstrbarriers_slopeclass03_km, - wct_belowupstrbarriers_slopeclass05_km = r.wct_belowupstrbarriers_slopeclass05_km, - wct_belowupstrbarriers_slopeclass08_km = r.wct_belowupstrbarriers_slopeclass08_km, - wct_belowupstrbarriers_slopeclass15_km = r.wct_belowupstrbarriers_slopeclass15_km, - wct_belowupstrbarriers_slopeclass22_km = r.wct_belowupstrbarriers_slopeclass22_km, - wct_belowupstrbarriers_slopeclass30_km = r.wct_belowupstrbarriers_slopeclass30_km, - - ch_spawning_belowupstrbarriers_km = r.ch_spawning_belowupstrbarriers_km, - ch_rearing_belowupstrbarriers_km = r.ch_rearing_belowupstrbarriers_km, - co_spawning_belowupstrbarriers_km = r.co_spawning_belowupstrbarriers_km, - co_rearing_belowupstrbarriers_km = r.co_rearing_belowupstrbarriers_km, - co_rearing_belowupstrbarriers_ha = r.co_rearing_belowupstrbarriers_ha, - sk_spawning_belowupstrbarriers_km = r.sk_spawning_belowupstrbarriers_km, - sk_rearing_belowupstrbarriers_km = r.sk_rearing_belowupstrbarriers_km, - sk_rearing_belowupstrbarriers_ha = r.sk_rearing_belowupstrbarriers_ha, - st_spawning_belowupstrbarriers_km = r.st_spawning_belowupstrbarriers_km, - st_rearing_belowupstrbarriers_km = r.st_rearing_belowupstrbarriers_km, - all_spawning_belowupstrbarriers_km = r.all_spawning_belowupstrbarriers_km, - all_rearing_belowupstrbarriers_km = r.all_rearing_belowupstrbarriers_km, - all_spawningrearing_belowupstrbarriers_km = r.all_spawningrearing_belowupstrbarriers_km -FROM report r -WHERE p.aggregated_crossings_id = r.aggregated_crossings_id; \ No newline at end of file diff --git a/reports/general/README.md b/reports/general/README.md deleted file mode 100644 index 2ba05507..00000000 --- a/reports/general/README.md +++ /dev/null @@ -1,4 +0,0 @@ -General reporting on barriers and modelled habitat, per watershed group - - psql2csv < sql/modelled_habitat.sql > modelled_habitat.csv - psql2csv < sql/habitat_blocked_by_barrier_type > habitat_blocked_by_barrier_type.csv \ No newline at end of file diff --git a/reports/general/sql/habitat_blocked_by_barrier_type.sql b/reports/general/sql/habitat_blocked_by_barrier_type.sql deleted file mode 100644 index e4bbd870..00000000 --- a/reports/general/sql/habitat_blocked_by_barrier_type.sql +++ /dev/null @@ -1,24 +0,0 @@ --- total potential habitat blocked by each barrier type -SELECT - watershed_group_code, - crossing_feature_type, - ROUND(SUM(ch_spawning_belowupstrbarriers_km)::numeric, 2) as ch_spawning_blocked_km, - ROUND(SUM(ch_rearing_belowupstrbarriers_km)::numeric, 2) as ch_rearing_blocked_km, - ROUND(SUM(co_spawning_belowupstrbarriers_km)::numeric, 2) as co_spawning_blocked_km, - ROUND(SUM(co_rearing_belowupstrbarriers_km)::numeric, 2) as co_rearing_blocked_km, - ROUND(SUM(sk_spawning_belowupstrbarriers_km)::numeric, 2) as sk_spawning_blocked_km, - ROUND(SUM(sk_rearing_belowupstrbarriers_km)::numeric, 2) as sk_rearing_blocked_km, - ROUND(SUM(st_spawning_belowupstrbarriers_km)::numeric, 2) as st_spawning_blocked_km, - ROUND(SUM(st_rearing_belowupstrbarriers_km)::numeric, 2) as st_rearing_blocked_km, - ROUND(SUM(all_spawning_belowupstrbarriers_km)::numeric, 2) as all_spawning_blocked_km, - ROUND(SUM(all_rearing_belowupstrbarriers_km)::numeric, 2) as all_rearing_blocked_km, - ROUND(SUM(all_spawningrearing_belowupstrbarriers_km)::numeric, 2) as all_spawningrearing_blocked_km -FROM bcfishpass.crossings -WHERE barrier_status IN ('POTENTIAL', 'BARRIER') -AND aggregated_crossings_id != '11e03b9a-0a3f-4022-b534-7e3de9eece2e' -- don't count the Elko Dam in ELKR -GROUP BY - watershed_group_code, - crossing_feature_type -ORDER BY - watershed_group_code, - crossing_feature_type \ No newline at end of file diff --git a/reports/general/sql/modelled_habitat.sql b/reports/general/sql/modelled_habitat.sql deleted file mode 100644 index 33f2e069..00000000 --- a/reports/general/sql/modelled_habitat.sql +++ /dev/null @@ -1,106 +0,0 @@ -select - watershed_group_code, - -- totals - COALESCE(ROUND((SUM(ST_Length(s.geom)::numeric) / 1000), 2), 0) AS total_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300)))) / 1000)::numeric, 2), 0) AS total_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS total_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS total_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .03 AND s.gradient < .05) / 1000))::numeric, 2), 0) as total_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .05 AND s.gradient < .08) / 1000))::numeric, 2), 0) as total_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .08 AND s.gradient < .15) / 1000))::numeric, 2), 0) as total_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .15 AND s.gradient < .22) / 1000))::numeric, 2), 0) as total_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.gradient >= .22 AND s.gradient < .30) / 1000))::numeric, 2), 0) as total_slopeclass30_km, - --- salmon model - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%') / 1000)::numeric), 2), 0) AS ch_co_sk_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS ch_co_sk_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_ch_co_sk LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS ch_co_sk_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_ch_co_sk LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS ch_co_sk_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as ch_co_sk_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as ch_co_sk_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as ch_co_sk_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as ch_co_sk_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk LIKE '%ACCESSIBLE%' AND (s.gradient >= .22 AND s.gradient < .3)) / 1000))::numeric, 2), 0) as ch_co_sk_slopeclass30_km, - --- steelhead - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%') / 1000)::numeric), 2), 0) AS st_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS st_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_st LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS st_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_st LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS st_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as st_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as st_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as st_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as st_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st LIKE '%ACCESSIBLE%' AND (s.gradient >= .22 AND s.gradient < .30)) / 1000))::numeric, 2), 0) as st_slopeclass30_km, - --- wct - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%') / 1000)::numeric), 2), 0) AS wct_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))))) / 1000)::numeric, 2), 0) AS wct_stream_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_wct LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type != 'R' OR (wb.waterbody_type IS NOT NULL AND s.edge_type NOT IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS wct_slopeclass03_waterbodies_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER ( - WHERE (s.model_access_wct LIKE '%ACCESSIBLE%') AND (s.gradient >= 0 AND s.gradient < .03) AND (wb.waterbody_type = 'R' OR (wb.waterbody_type IS NULL AND s.edge_type IN (1000,1100,2000,2300))) - )) / 1000)::numeric, 2), 0) AS wct_slopeclass03_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (s.gradient >= .03 AND s.gradient < .05)) / 1000))::numeric, 2), 0) as wct_slopeclass05_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (s.gradient >= .05 AND s.gradient < .08)) / 1000))::numeric, 2), 0) as wct_slopeclass08_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (s.gradient >= .08 AND s.gradient < .15)) / 1000))::numeric, 2), 0) as wct_slopeclass15_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (s.gradient >= .15 AND s.gradient < .22)) / 1000))::numeric, 2), 0) as wct_slopeclass22_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct LIKE '%ACCESSIBLE%' AND (s.gradient >= .22 AND s.gradient < .30)) / 1000))::numeric, 2), 0) as wct_slopeclass30_km, - - --- habitat models - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_co IS TRUE) / 1000))::numeric, 2), 0) AS co_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_co IS TRUE) / 1000))::numeric, 2), 0) AS co_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_st IS TRUE) / 1000))::numeric, 2), 0) AS st_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_st IS TRUE) / 1000))::numeric, 2), 0) AS st_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_cm IS TRUE) / 1000))::numeric, 2), 0) AS cm_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_pk IS TRUE) / 1000))::numeric, 2), 0) AS pk_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawning_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE - ) / 1000))::numeric, 2), 0) AS all_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE OR - s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawningrearing_km -from bcfishpass.streams s -left outer join whse_basemapping.fwa_waterbodies wb on s.waterbody_key = wb.waterbody_key -group by watershed_group_code; diff --git a/reports/general/sql/totals.sql b/reports/general/sql/totals.sql deleted file mode 100644 index 473f48e8..00000000 --- a/reports/general/sql/totals.sql +++ /dev/null @@ -1,55 +0,0 @@ -with totals as ( - select - watershed_group_code, - COALESCE(ROUND((SUM(ST_Length(s.geom)::numeric) / 1000), 2), 0) AS total_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_ch_co_sk IS NOT NULL) / 1000)::numeric), 2), 0) AS ch_co_sk_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_st IS NOT NULL) / 1000)::numeric), 2), 0) AS st_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_access_wct IS NOT NULL) / 1000)::numeric), 2), 0) AS wct_network_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE) / 1000))::numeric, 2), 0) AS ch_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_co IS TRUE) / 1000))::numeric, 2), 0) AS co_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_co IS TRUE) / 1000))::numeric, 2), 0) AS co_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_sk IS TRUE) / 1000))::numeric, 2), 0) AS sk_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_st IS TRUE) / 1000))::numeric, 2), 0) AS st_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_st IS TRUE) / 1000))::numeric, 2), 0) AS st_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_wct IS TRUE) / 1000))::numeric, 2), 0) AS wct_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_cm IS TRUE) / 1000))::numeric, 2), 0) AS cm_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_pk IS TRUE) / 1000))::numeric, 2), 0) AS pk_spawning_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawning_km, - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE - ) / 1000))::numeric, 2), 0) AS all_rearing_km , - COALESCE(ROUND(((SUM(ST_Length(s.geom)) FILTER (WHERE s.model_spawning_ch IS TRUE OR - s.model_spawning_co IS TRUE OR - s.model_spawning_sk IS TRUE OR - s.model_spawning_st IS TRUE OR - s.model_spawning_wct IS TRUE OR - s.model_spawning_cm IS TRUE OR - s.model_spawning_pk IS TRUE OR - s.model_rearing_ch IS TRUE OR - s.model_rearing_co IS TRUE OR - s.model_rearing_sk IS TRUE OR - s.model_rearing_st IS TRUE OR - s.model_rearing_wct IS TRUE - ) / 1000))::numeric, 2), 0) AS all_spawningrearing_km - from bcfishpass.streams s - group by watershed_group_code -) - -insert into bcfishpass.totals -select - date_trunc('minute', now()) as date_processed, - * -from totals order by watershed_group_code; \ No newline at end of file