bmaitner / RBIEN

Tools for accessing the Botanical Information and Ecology Network (BIEN) database
http://bien.nceas.ucsb.edu/bien/
Other
43 stars 10 forks source link

Can't download plot data with specific sampling protocol #21

Open Rekyt opened 4 years ago

Rekyt commented 4 years ago

Hey @bmaitner, I'm trying to work with BIEN plot data. As mentioned by the tutorial it is better to work with plots acquired through similar sampling protocol to be comparable. However, when trying to download from a specific protocol I get no results for most of them. Here's the reprex:

all_protocols = BIEN::BIEN_plot_list_sampling_protocols()

# "1 ha tree plot, stems >= 10 cm dbh"
BIEN::BIEN_plot_sampling_protocol(all_protocols[3, 1])
#> data frame with 0 columns and 0 rows

# "Carolina Vegetation Survey Standard Sampling Method"
BIEN::BIEN_plot_sampling_protocol(all_protocols[4, 1])
#> data frame with 0 columns and 0 rows

# "Center for Tropical Forest Science Forest Inventory  Protocol"
BIEN::BIEN_plot_sampling_protocol(all_protocols[5, 1])
#> data frame with 0 columns and 0 rows

# "TEAM Forest Inventory Sampling Protocol"
BIEN::BIEN_plot_sampling_protocol(all_protocols[7, 1])
#> data frame with 0 columns and 0 rows

# "US Forest Inventory and Analysis Sampling Protocol"
BIEN::BIEN_plot_sampling_protocol(all_protocols[8, 1])
#> data frame with 0 columns and 0 rows

Created on 2020-11-10 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.0.2 (2020-06-22) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate French_France.1252 #> ctype French_France.1252 #> tz Europe/Berlin #> date 2020-11-10 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> ape 5.4-1 2020-08-13 [1] CRAN (R 4.0.3) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3) #> backports 1.2.0 2020-11-02 [1] CRAN (R 4.0.2) #> BIEN 1.2.4 2020-02-27 [1] CRAN (R 4.0.3) #> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3) #> class 7.3-17 2020-04-26 [2] CRAN (R 4.0.2) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.3) #> cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.3) #> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.0.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3) #> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3) #> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.3) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3) #> doParallel 1.0.16 2020-10-16 [1] CRAN (R 4.0.3) #> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.3) #> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.3) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3) #> fasterize 1.0.3 2020-07-27 [1] CRAN (R 4.0.3) #> foreach 1.5.1 2020-10-15 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.3) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.3) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.3) #> iterators 1.0.13 2020-10-15 [1] CRAN (R 4.0.3) #> KernSmooth 2.23-18 2020-10-29 [1] CRAN (R 4.0.3) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.3) #> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.2) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.3) #> nlme 3.1-150 2020-10-24 [1] CRAN (R 4.0.3) #> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.3) #> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3) #> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.3) #> ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.3) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3) #> raster 3.3-13 2020-07-17 [1] CRAN (R 4.0.3) #> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.3) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.3) #> rgeos 0.5-5 2020-09-07 [1] CRAN (R 4.0.3) #> rlang 0.4.8 2020-10-08 [1] CRAN (R 4.0.3) #> rmarkdown 2.5 2020-10-21 [1] CRAN (R 4.0.3) #> RPostgreSQL 0.6-2 2017-06-24 [1] CRAN (R 4.0.3) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3) #> sf 0.9-6 2020-09-13 [1] CRAN (R 4.0.3) #> sp 1.4-4 2020-10-07 [1] CRAN (R 4.0.3) #> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.3) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.3) #> testthat 3.0.0 2020-10-31 [1] CRAN (R 4.0.3) #> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.3) #> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.3) #> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.3) #> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.3) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3) #> xfun 0.19 2020-10-30 [1] CRAN (R 4.0.3) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3) #> #> [1] C:/Users/ke76dimu/Documents/R/win-library/4.0 #> [2] C:/Program Files/R/R-4.0.2/library ```
Rekyt commented 4 years ago

Looking into more details it seems that most sampling protocols don't match with what is reported in the view_full_occurrence_individual, these are the protocols I get from the sampling_protocol column in the view:

tibble::as_tibble(BIEN:::.BIEN_sql("SELECT DISTINCT sampling_protocol  FROM view_full_occurrence_individual"))
#> # A tibble: 24 x 1
#>    sampling_protocol                                                            
#>    <chr>                                                                        
#>  1 0.01 ha, stems >= 10 cm dbh; 16 subplots of 10 x 10 m per plot, 4 rows (UU, ~
#>  2 0.1 ha  transect, stems >= 2.5 cm dbh                                        
#>  3 1 ha, stems >= 10 cm dbh                                                     
#>  4 All species recorded in a circle of 5 km radius, centered on the geocoordina~
#>  5 Area of each plot was estimated, not based on actual measurements.           
#>  6 Carolina Vegetation Survey Standard Sampling Method.  See http://www.bio.unc~
#>  7 Cover only                                                                   
#>  8 Cover values are derived from cover below 1m observed in 25 1m^2 plots suppl~
#>  9 CVS protocol.  2 module plot with 150% supersample for trees >=10cm in DBH. ~
#> 10 CVS Protocol.  Pines >=2.5 cm DBH supersampled at 125%                       
#> # ... with 14 more rows

Created on 2020-11-10 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.0.2 (2020-06-22) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate French_France.1252 #> ctype French_France.1252 #> tz Europe/Berlin #> date 2020-11-10 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> ape 5.4-1 2020-08-13 [1] CRAN (R 4.0.3) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3) #> backports 1.2.0 2020-11-02 [1] CRAN (R 4.0.2) #> BIEN 1.2.4 2020-02-27 [1] CRAN (R 4.0.3) #> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3) #> class 7.3-17 2020-04-26 [2] CRAN (R 4.0.2) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.3) #> cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.3) #> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.0.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3) #> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3) #> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.3) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3) #> doParallel 1.0.16 2020-10-16 [1] CRAN (R 4.0.3) #> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.3) #> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.3) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3) #> fasterize 1.0.3 2020-07-27 [1] CRAN (R 4.0.3) #> foreach 1.5.1 2020-10-15 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.3) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.3) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.3) #> iterators 1.0.13 2020-10-15 [1] CRAN (R 4.0.3) #> KernSmooth 2.23-18 2020-10-29 [1] CRAN (R 4.0.3) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.3) #> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.2) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.3) #> nlme 3.1-150 2020-10-24 [1] CRAN (R 4.0.3) #> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.3) #> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3) #> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.3) #> ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.3) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3) #> raster 3.3-13 2020-07-17 [1] CRAN (R 4.0.3) #> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.3) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.3) #> rgeos 0.5-5 2020-09-07 [1] CRAN (R 4.0.3) #> rlang 0.4.8 2020-10-08 [1] CRAN (R 4.0.3) #> rmarkdown 2.5 2020-10-21 [1] CRAN (R 4.0.3) #> RPostgreSQL 0.6-2 2017-06-24 [1] CRAN (R 4.0.3) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3) #> sf 0.9-6 2020-09-13 [1] CRAN (R 4.0.3) #> sp 1.4-4 2020-10-07 [1] CRAN (R 4.0.3) #> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.3) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.3) #> testthat 3.0.0 2020-10-31 [1] CRAN (R 4.0.3) #> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.3) #> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.3) #> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.3) #> utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.3) #> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.3) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3) #> xfun 0.19 2020-10-30 [1] CRAN (R 4.0.3) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3) #> #> [1] C:/Users/ke76dimu/Documents/R/win-library/4.0 #> [2] C:/Program Files/R/R-4.0.2/library ```

There is a discrepancy between the sampling_protocol column provided by BIEN::BIEN_plot_list_sampling_protocols() and the sampling_protocol column in view_full_occurrence_individual. Looking at the code of BIEN_plot_list_sampling_protocols() this means there is a discrepancy between the sampling_protocol column in plot_metadata table and view_full_occurrence_individual. So which one should be the good one?

bmaitner commented 4 years ago

Thanks for letting me know about this @Rekyt . This discrepancy must have crept in during one of the database updates. I'll dig into this and get back to you shortly

OndrejMottl commented 1 year ago

Is there any development with the Issue? I am still getting the same problem as @Rekyt.

OndrejMottl commented 1 year ago

The solution presented by @Rekyt does not solve the situation as the sampling_protocol from view_full_occurrence_individual also does not return anything from BIEN::BIEN_plot_sampling_protocol()