NewGraphEnvironment / fish_passage_peace_2023_reporting

https://newgraphenvironment.github.io/fish_passage_peace_2023_reporting/
Creative Commons Zero v1.0 Universal
0 stars 2 forks source link

Interactive planning dashboard filtering out all bcfishpass rows due to `dplyr::filter(is.na(barriers_anthropogenic_dnstr))` #58

Closed NewGraphEnvironment closed 6 months ago

NewGraphEnvironment commented 6 months ago

Looks like the dams are in there still

bcfishpass |> 
  fpr::fpr_sp_assign_sf_from_utm(col_easting = "utm_easting", col_northing = "utm_northing") |> 
  # st_as_sf(coords = c('utm_easting', 'utm_northing'), crs = 26910, remove = F) %>% 
  dplyr::filter(is.na(pscis_status) | (pscis_status != 'HABITAT CONFIRMATION' &
                                         barrier_status != 'PASSABLE' &
                                         barrier_status != 'UNKNOWN')) |> 
  dplyr::filter(bt_rearing_km > 0.499) |> 
  dplyr::filter(crossing_type_code != 'OBS') |> 
  dplyr::group_by(barriers_anthropogenic_dnstr) |> 
  dplyr::summarise(n = n()) |> 
  dplyr::arrange(desc(n)) |> 
  sf::st_drop_geometry() |> 
  head(5)

# A tibble: 5 × 2
  barriers_anthropogenic_dnstr                                                                                                               n
  <chr>                                                                                                                                  <int>
1 785afb41-dfdf-423c-a291-e213d4b44f26;320902cd-48fc-40e5-8c0f-191086f332aa;957546a9-e6c7-46bf-947a-b17d8a818d71                           286
2 198662;785afb41-dfdf-423c-a291-e213d4b44f26;320902cd-48fc-40e5-8c0f-191086f332aa;957546a9-e6c7-46bf-947a-b17d8a818d71                     10
3 125355;57718;1016603910;785afb41-dfdf-423c-a291-e213d4b44f26;320902cd-48fc-40e5-8c0f-191086f332aa;957546a9-e6c7-46bf-947a-b17d8a818d71     9
4 1024743484;785afb41-dfdf-423c-a291-e213d4b44f26;320902cd-48fc-40e5-8c0f-191086f332aa;957546a9-e6c7-46bf-947a-b17d8a818d71                  5
5 6539;785afb41-dfdf-423c-a291-e213d4b44f26;320902cd-48fc-40e5-8c0f-191086f332aa;957546a9-e6c7-46bf-947a-b17d8a818d71                        5
NewGraphEnvironment commented 6 months ago
fpr::fpr_db_query("SELECT * FROM bcfishpass.barriers_anthropogenic WHERE barriers_anthropogenic_id IN ('785afb41-dfdf-423c-a291-e213d4b44f26','320902cd-48fc-40e5-8c0f-191086f332aa','957546a9-e6c7-46bf-947a-b17d8a818d71')")
#> Query time = 1.3 seconds!
#> Simple feature collection with 3 features and 10 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 1236682 ymin: 1227875 xmax: 1314500 ymax: 1256071
#> Projected CRS: NAD83 / BC Albers
#>              barriers_anthropogenic_id barrier_type barrier_name
#> 1 320902cd-48fc-40e5-8c0f-191086f332aa          DAM         <NA>
#> 2 785afb41-dfdf-423c-a291-e213d4b44f26          DAM         <NA>
#> 3 957546a9-e6c7-46bf-947a-b17d8a818d71          DAM         <NA>
#>   linear_feature_id blue_line_key watershed_key downstream_route_measure
#> 1         234041162     359572348     359572348                  1684325
#> 2         166059171     359572348     359572348                  1706738
#> 3         234019095     359572348     359572348                  1597446
#>   wscode_ltree   localcode_ltree watershed_group_code                    geom
#> 1   200.948755 200.948755.861026                 UPCE POINT (1249342 1227875)
#> 2   200.948755 200.948755.871814                 PCEA POINT (1236682 1230968)
#> 3   200.948755 200.948755.816999                 UPCE POINT (1314500 1256071)

Created on 2024-05-28 with reprex v2.1.0

NewGraphEnvironment commented 6 months ago

solution

dams <- c('785afb41-dfdf-423c-a291-e213d4b44f26',
          '320902cd-48fc-40e5-8c0f-191086f332aa',
          '957546a9-e6c7-46bf-947a-b17d8a818d71')

then when generating df to build dashboard with

... |>
dplyr::filter(is.na(barriers_anthropogenic_dnstr) |
         str_detect(barriers_anthropogenic_dnstr, paste(dams, collapse = "|")))