NewGraphEnvironment / rfp

Reproducible Field Projects British Columbia
Other
0 stars 0 forks source link

rename `rfp_xref_fwa_wshd_groups` to `rfp_xref_fwa_wsg` #5

Closed NewGraphEnvironment closed 3 months ago

NewGraphEnvironment commented 3 months ago

doh - forgot about that nameing convention. good to catch before used anywhere. WIAN

NewGraphEnvironment commented 3 months ago

hmm. Why start storing STABLE data in packages and calling as functions when we can create them easily multiple ways? Reopening so can close with function removal.

Can still make sense to store as object in repos to avoid calling outside of the repo to produce the gitpages (or any other product)

interesting that calling to remote pg database is 15 times faster than using R bcdata via rfp::rfp_bcd_get_data

system.time(
  rfp_xref_fwa_wsg <- rfp::rfp_bcd_get_data(
    bcdata_record_id = stringr::str_to_upper("whse_basemapping.fwa_watershed_groups_poly"),
    col_extract = stringr::str_to_upper(c("watershed_group_code", "watershed_group_name")),
    drop_geom = TRUE
  ) |> 
    dplyr::arrange(watershed_group_code) 
)
#>    user  system elapsed 
#>  15.366   1.255  24.650

system.time(
  rfp_xref_fwa_wsg2 <- fpr::fpr_db_query(
    query= "SELECT watershed_group_code, watershed_group_name
  FROM whse_basemapping.fwa_watershed_groups_poly"
  ) |> 
    dplyr::arrange(watershed_group_code)
)
#> Warning in st_read.DBIObject(conn, query = query): Could not find a simple
#> features geometry column. Will return a `data.frame`.
#> Query time = 1.4 seconds!
#>    user  system elapsed 
#>   0.153   0.022   1.537

identical(rfp_xref_fwa_wsg, rfp_xref_fwa_wsg2)
#> [1] FALSE
waldo::compare(rfp_xref_fwa_wsg, rfp_xref_fwa_wsg2)
#> `class(old)`: "bcdc_sf" "tbl_df" "tbl" "data.frame"
#> `class(new)`:                          "data.frame"
#> 
#> `attr(old, 'full_url')` is a character vector ('https://openmaps.gov.bc.ca/geo/pub/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&outputFormat=application%2Fjson&typeNames=WHSE_BASEMAPPING.FWA_WATERSHED_GROUPS_POLY&SRSNAME=EPSG%3A3005')
#> `attr(new, 'full_url')` is absent
#> 
#> `attr(old, 'query_list')` is a list
#> `attr(new, 'query_list')` is absent
#> 
#> `attr(old, 'time_downloaded')` is an S3 object of class <POSIXct/POSIXt>, a double vector
#> `attr(new, 'time_downloaded')` is absent
#> 
#> `attr(old, 'url')` is a character vector ('https://openmaps.gov.bc.ca/geo/pub/wfs')
#> `attr(new, 'url')` is absent

Created on 2024-04-16 with reprex v2.1.0