Skip to content

Commit

Permalink
Merge branch 'main' of github.com:smnorris/bcfishpass
Browse files Browse the repository at this point in the history
* 'main' of github.com:smnorris/bcfishpass:
  fix #395, fix #397 (#404)
  • Loading branch information
smnorris committed Sep 11, 2023
2 parents 3a61e8a + 22cfae4 commit 36cdb3e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 90 deletions.
1 change: 0 additions & 1 deletion data/dfo_known_sockeye_lakes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ waterbody_poly_id
710002604
120059414
154082735
120059396
124070891
141085626
93077471
Expand Down
1 change: 1 addition & 0 deletions data/user_barriers_definite.csv
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,4 @@ MISC,,356255112,2014,HORS,CWF,2021-01-01,CWF WCRP,based on assessment comments (
MISC,,356351031,2473,LNIC,CWF,2023-04-11,CWF WCRP,impassable natural barrier ~21 km marker on Prospect Creek FSR; approximate location in form but would need to be updated
MISC,,356364423,7707,QUES,CWF,2023-04-25,CWF WCRP,"Beaver Falls are a hard barrier, based on information provided by participants at LDN workshop."
MISC,,356342526,110,BOWR,CWF,2023-04-25,CWF WCRP,"Alluvial fan based on information provided by participants at LDN workshop (Chris Elden, West Fraser)."
GRADIENT_25,,360874126,463.62,LRDO,SN,2023-09-05,https://a100.gov.bc.ca/pub/acat/documents/r585/whalen_report_1068061634267_b3539f3bfa6440d4af43a65105c6e978.pdf,no anadromous spp in Whalen Lake CO; observations upstream are stocked
92 changes: 47 additions & 45 deletions model/01_access/sql/model_access_ch_cm_co_pk_sk.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ with barriers as
geom
from bcfishpass.barriers_subsurfaceflow
where watershed_group_code = :'wsg'
union all
select
barriers_user_definite_id as barrier_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from bcfishpass.barriers_user_definite
where watershed_group_code = :'wsg'
),

obs_upstr as
Expand Down Expand Up @@ -181,6 +167,38 @@ hab_upstr as
1
)
group by b.barrier_id
),

barriers_filtered as (
select
b.barrier_id as barrier_load_id,
b.barrier_type,
b.barrier_name,
b.linear_feature_id,
b.blue_line_key,
b.downstream_route_measure,
b.wscode_ltree,
b.localcode_ltree,
b.watershed_group_code,
b.geom
from barriers b
left outer join obs_upstr_n as o on b.barrier_id = o.barrier_id
left outer join hab_upstr h on b.barrier_id = h.barrier_id
where watershed_group_code = any(
array(
select watershed_group_code
from bcfishpass.wsg_species_presence
where ch is true or cm is true or co is true or pk is true or sk is true
)
)
-- do not include gradient / falls / subsurface barriers with
-- - > 5 observations upstream
-- - confirmed habitat upstream
and
(
(o.n_obs is null or o.n_obs < 5) and
h.species_codes is null
)
)

insert into bcfishpass.barriers_ch_cm_co_pk_sk
Expand All @@ -197,36 +215,20 @@ insert into bcfishpass.barriers_ch_cm_co_pk_sk
geom
)

select * from barriers_filtered
union all
select
b.barrier_id as barrier_load_id,
b.barrier_type,
b.barrier_name,
b.linear_feature_id,
b.blue_line_key,
b.downstream_route_measure,
b.wscode_ltree,
b.localcode_ltree,
b.watershed_group_code,
b.geom
from barriers b
left outer join obs_upstr_n as o on b.barrier_id = o.barrier_id
left outer join hab_upstr h on b.barrier_id = h.barrier_id
where watershed_group_code = any(
array(
select watershed_group_code
from bcfishpass.wsg_species_presence
where ch is true or cm is true or co is true or pk is true or sk is true
)
)
-- do not include gradient / falls / subsurface barriers with
-- - > 5 observations upstream
-- - confirmed habitat upstream
-- but always include user added barriers
and (
(
(o.n_obs is null or o.n_obs < 5) and
h.species_codes is null
) or
b.barrier_type in ('EXCLUSION', 'PSCIS_NOT_ACCESSIBLE', 'MISC')
)
barriers_user_definite_id as barrier_load_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from bcfishpass.barriers_user_definite
where watershed_group_code = :'wsg'

on conflict do nothing;
89 changes: 45 additions & 44 deletions model/01_access/sql/model_access_st.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,6 @@ with barriers as
geom
from bcfishpass.barriers_subsurfaceflow
where watershed_group_code = :'wsg'
union all
select
barriers_user_definite_id as barrier_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from bcfishpass.barriers_user_definite
where watershed_group_code = :'wsg'
),

obs_upstr as
Expand Down Expand Up @@ -167,6 +153,37 @@ hab_upstr as
1
)
group by b.barrier_id
),

barriers_filtered as (
select
b.barrier_id as barrier_load_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from barriers b
left outer join obs_upstr_n as o on b.barrier_id = o.barrier_id
left outer join hab_upstr h on b.barrier_id = h.barrier_id
where watershed_group_code = any(
array(
select watershed_group_code
from bcfishpass.wsg_species_presence
where st is true
)
)
-- do not include gradient / falls / subsurface barriers with > 5 observations upstream
-- but always include user added barriers
and
(
(o.n_obs is null or o.n_obs < 5) and
h.species_codes is null
)
)

insert into bcfishpass.barriers_st
Expand All @@ -182,35 +199,19 @@ insert into bcfishpass.barriers_st
watershed_group_code,
geom
)

select * from barriers_filtered
union all
select
b.barrier_id as barrier_load_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from barriers b
left outer join obs_upstr_n as o on b.barrier_id = o.barrier_id
left outer join hab_upstr h on b.barrier_id = h.barrier_id
where watershed_group_code = any(
array(
select watershed_group_code
from bcfishpass.wsg_species_presence
where st is true
)
)
-- do not include gradient / falls / subsurface barriers with > 5 observations upstream
-- but always include user added barriers
and (
(
(o.n_obs is null or o.n_obs < 5) and
h.species_codes is null
) or
b.barrier_type in ('EXCLUSION', 'PSCIS_NOT_ACCESSIBLE', 'MISC')
)
barriers_user_definite_id as barrier_load_id,
barrier_type,
barrier_name,
linear_feature_id,
blue_line_key,
downstream_route_measure,
wscode_ltree,
localcode_ltree,
watershed_group_code,
geom
from bcfishpass.barriers_user_definite
where watershed_group_code = :'wsg'
on conflict do nothing;

0 comments on commit 36cdb3e

Please sign in to comment.