poissonconsulting / fwapgr

An R Client for BC Freshwater Atlas Web API
https://poissonconsulting.github.io/fwapgr
Other
8 stars 1 forks source link

functions failing on first attempt with ! Must extract column with a single valid subscript #57

Closed NewGraphEnvironment closed 2 years ago

NewGraphEnvironment commented 2 years ago

Guessing this is something to do my personal setup but with a bunch of troubleshooting I can't seem to figure it out. See example below

coll <- "whse_basemapping.fwa_stream_networks_sp"

river <- fwapgr::fwa_query_collection(coll, filter = list(gnis_name = "Sangan River"))

on the first attempt this throws the error below. However, if I try again it works. Seems bizarre.

Error: ! Must extract column with a single valid subscript. x Subscriptattr(obj, "sf_column")has size 0 but must be size 1. Runrlang::last_error()` to see where the error occurred.

rlang::last_error() <error/vctrs_error_subscript_type> Error: ! Must extract column with a single valid subscript. x Subscript attr(obj, "sf_column") has size 0 but must be size 1. Backtrace:

  1. fwapgr::fwa_query_collection(coll, filter = list(gnis_name = "Sangan River"))
  2. sf:::st_transform.sf(x, epsg)
  3. sf:::st_geometry.sf(x)
  4. tibble:::[[.tbl_df(obj, attr(obj, "sf_column"))
  5. tibble:::tbl_subset2(x, j = i, j_arg = substitute(i))
  6. tibble:::vectbl_as_col_location2(j, length(x), names(x), j_arg = j_arg)
  7. vctrs::vec_as_location2(j, n, names)
  8. vctrs:::result_get(...) Run rlang::last_trace() to see the full context. rlang::last_trace() <error/vctrs_error_subscript_type> Error: ! Must extract column with a single valid subscript. x Subscript attr(obj, "sf_column") has size 0 but must be size 1. Backtrace: x
  9. -fwapgr::fwa_query_collection(coll, filter = list(gnis_name = "Sangan River"))
  10. +-sf::st_transform(x, epsg)
  11. -sf:::st_transform.sf(x, epsg)
  12. +-sf::st_transform(st_geometry(x), crs, ...)
  13. +-sf::st_geometry(x)
  14. -sf:::st_geometry.sf(x)
  15. +-obj[[attr(obj, "sf_column")]]
  16. -tibble:::[[.tbl_df(obj, attr(obj, "sf_column"))
  17. -tibble:::tbl_subset2(x, j = i, j_arg = substitute(i))
  18. -tibble:::vectbl_as_col_location2(j, length(x), names(x), j_arg = j_arg)
  19. +-tibble:::subclass_col_index_errors(...)
  20. | -base::withCallingHandlers(...)
  21. -vctrs::vec_as_location2(j, n, names)
  22. -vctrs:::result_get(...)
  23. -rlang::cnd_signal(x$err)`

sessionInfo() R version 4.0.5 (2021-03-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] Rcpp_1.0.8 rstudioapi_0.13 fwapgr_0.1.0.9011 magrittr_2.0.2 units_0.8-0
[6] tidyselect_1.1.1 R6_2.5.1 rlang_1.0.1 fansi_1.0.2 httr_1.4.2
[11] dplyr_1.0.6 tools_4.0.5 grid_4.0.5 utf8_1.2.2 KernSmooth_2.23-18
[16] cli_3.2.0 e1071_1.7-9 DBI_1.1.2 ellipsis_0.3.2 class_7.3-18
[21] assertthat_0.2.1 tibble_3.1.6 lifecycle_1.0.1 crayon_1.5.0 pgfeatureserv_0.0.0.9001 [26] sf_1.0-6 purrr_0.3.4 vctrs_0.3.8 curl_4.3 glue_1.6.2
[31] geojsonsf_2.0.1 proxy_0.4-26 compiler_4.0.5 pillar_1.7.0 chk_0.8.0.9000
[36] generics_0.1.2 classInt_0.4-3 pkgconfig_2.0.3

joethorley commented 2 years ago

Works fine on my machine but I'm on R 4.1.2 - I'd try updating everything