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:
  Update join_tracking_table_crossings_vw.sql (#599)
  Elk exclusions list updates (#597)
  Update join_tracking_table_crossings_vw.sql (#596)
  • Loading branch information
smnorris committed Nov 22, 2024
2 parents c8ec55c + 66069a5 commit 45c4f05
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 6 deletions.
2 changes: 1 addition & 1 deletion data/pscis_modelledcrossings_streams_xref.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ stream_crossing_id,modelled_crossing_id,linear_feature_id,watershed_group_code,r
112333,4606301,,ELKR,,
112334,4606298,,ELKR,,
112335,,,ELKR,,
112336,,706832864,ELKR,,
112336,,,ELKR,MC,On unmapped tributary. Nothing to match to
112337,4606616,,ELKR,,
112338,,,ELKR,,
112339,4606303,,ELKR,,
Expand Down
3 changes: 3 additions & 0 deletions data/user_modelled_crossing_fixes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -21087,3 +21087,6 @@ modelled_crossing_id,structure,watershed_group_code,reviewer_name,review_date,so
11302064,NONE,LNIC,LB,2024-07-16,imagery,Ortho image indicates the stream has likely migrated/been redirected to the north and no longer crosses this road.
11301333,OBS,LNIC,LB,2024-07-16,imagery,Appears to be a bridge on sat imagery- stream goes to north of where it's mapped
2300291,NONE,CARR,LB,2024-11-04,Lhtako Dene WCRP Field Assessment 2023,"River left has an old concrete, log, and metal cribbing structure located on the bank immediately adjacent to the stream, perhaps used to draft water from stream. Large angle iron driven vertically into stream bed and intake pipe visible in stream bed. No manmade barrier to fish passage at this location but there is a beaver dam present immediately downstream of structure"
1004605216,NONE,ELKR,MC,2024-11-08,Elk WCRP excluded structures list,
1024735443,NONE,ELKR,MC,2024-11-08,Elk WCRP excluded structures list,Recreational trail erroneously mapped in Digital Road Atlas
1004606284,FORD,ELKR,MC,2024-11-08,Elk WCRP excluded structures list,Confirmed via literature: Cope et al. (2016)
124 changes: 119 additions & 5 deletions db/v0.5.3/sql/join_tracking_table_crossings_vw.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,126 @@ as
$$
begin
execute format('create or replace view wcrp_%I.combined_tracking_table_crossings_wcrp_vw_%I as
select
cv.*,
tt.*
select
case
when tt.barrier_id is not null then tt.barrier_id
else cv.aggregated_crossings_id
end as barrier_id,
cv.crossing_source,
cv.crossing_feature_type,
cv.pscis_status,
cv.crossing_type_code,
cv.crossing_subtype_code,
cv.barrier_status,
cv.pscis_road_name,
cv.pscis_stream_name,
cv.pscis_assessment_comment,
cv.pscis_assessment_date,
cv.transport_line_structured_name_1,
cv.rail_track_name,
cv.dam_name,
cv.dam_height,
cv.dam_owner,
cv.dam_use,
cv.dam_operating_status,
cv.utm_zone,
cv.utm_easting,
cv.utm_northing,
cv.blue_line_key,
cv.downstream_route_measure,
cv.wscode,
cv.localcode,
cv.watershed_group_code,
cv.gnis_stream_name,
cv.barriers_anthropogenic_dnstr,
cv.barriers_anthropogenic_dnstr_count,
cv.barriers_anthropogenic_habitat_wcrp_upstr
cv.barriers_antrhopogenic_habitat_wcrp_upstr_count,
cv.barriers_ch_cm_co_pk_sk_dnstr,
cv.barriers_st_dnstr,
cv.barriers_wct_dnstr,
cv.ch_spawning_km,
cv.ch_rearing_km,
cv.ch_spawning_belowupstrbarriers_km,
cv.ch_rearing_belowupstrbarriers_km,
cv.cm_spawning_km,
cv.cm_spawning_belowupstrbarriers_km,
cv.co_spawning_km,
cv.co_rearing_km,
cv.co_rearing_ha,
cv.co_spawning_belowupstrbarriers_km,
cv.co_rearing_belowupstrbarriers_km,
cv.co_rearing_belowupstrbarriers_ha,
cv.pk_spawning_km,
cv.pk_spawning_belowupstrbarriers_km,
cv.sk_spawning_km,
cv.sk_rearing_km,
cv.sk_rearing_ha,
cv.sk_spawning_belowupstrbarriers_km,
cv.sk_rearing_belowupstrbarriers_km,
cv.sk_rearing_belowupstrbarriers_ha,
cv.st_spawning_km,
cv.st_rearing_km,
cv.st_spawning_belowupstrbarriers_km,
cv.st_rearing_belowupstrbarriers_km,
cv.wct_spawning_km,
cv.wct_rearing_km,
cv.wct_spawning_belowupstrbarriers_km,
cv.wct_rearing_belowupstrbarriers_km,
cv.all_spawning_km,
cv.all_spawning_belowupstrbarriers_km,
cv.all_rearing_km,
cv.all_rearing_belowupstrbarriers_km,
cv.all_spawningrearing_km,
cv.all_spawningrearing_belowupstrbarriers_km,
cv.set_id,
cv.total_hab_gain_set,
cv.num_barriers_set,
cv.avg_gain_per_barrier,
cv.dnstr_set_ids,
cv.rank_avg_gain_per_barrier,
cv.rank_avg_gain_tiered,
cv.rank_total_upstr_hab,
cv.rank_combined,
cv.tier_combined,
cv.geom,
tt.internal_name,
tt.watercourse_name,
tt.road_name,
tt.structure_type,
tt.structure_owner,
tt.private_owner_details,
tt.structure_list_status,
tt.assessment_type_completed,
tt.reason_for_exclusion,
tt.method_of_exclusion,
tt.partial_passability,
tt.partial_passability_notes,
tt.upstream_habitat_quality,
tt.constructability,
tt.estimated_cost_$,
tt.priority,
tt.type_of_rehabilitation,
tt.rehabilitated_by,
tt.rehabilitated_date,
tt.estimated_rehabilitation_cost_$,
tt.actual_project_cost_$,
tt.next_steps,
tt.timeline_for_next_steps,
tt.lead_for_next_steps,
tt.others_involved_in_next_steps,
tt.reason,
tt.notes,
tt.supporting_links
from bcfishpass.crossings_wcrp_vw cv
join wcrp_%I.combined_tracking_table_%I tt
on tt.barrier_id = cv.aggregated_crossings_id', p_wcrp, p_wcrp, p_wcrp, p_wcrp);
full outer join wcrp_%I.combined_tracking_table_%I tt
on tt.barrier_id = cv.aggregated_crossings_id
where (cv.watershed_group_code in
(select watershed_group_code
from bcfishpass.wcrp_watersheds
where wcrp ilike %L)
and cv.all_spawningrearing_km > 0)
or tt.barrier_id is not null', p_wcrp, p_wcrp, p_wcrp, p_wcrp, p_wcrp);
end
$$
language plpgsql;
Expand Down

0 comments on commit 45c4f05

Please sign in to comment.