Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always return latitude and longitude as numeric values #247

Open
dlebauer opened this issue Sep 23, 2021 · 1 comment
Open

always return latitude and longitude as numeric values #247

dlebauer opened this issue Sep 23, 2021 · 1 comment

Comments

@dlebauer
Copy link
Contributor

dlebauer commented Sep 23, 2021

This example (w/ GBIF) works as expected:

library(mapr)
library(spocc)
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 50, has_coords = TRUE)
map_leaflet(dat)

As does this one from iNaturalist, after changing the 'occdat' object to sp

spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ2sp(occ(spp, from = 'inat', limit = 50, has_coords = TRUE))
map_leaflet(dat)

This example doesn't work, because (lat, lon) are returned as characters:

library(mapr)
#> Warning: package 'mapr' was built under R version 4.0.5
library(spocc)
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'inat', limit = 50, has_coords = TRUE)
map_leaflet(dat)
#> Error in validateCoords(lng, lat, funcName): addCircleMarkers requires numeric longitude/latitude values

NB: I am assuming the goal is to standardize the returned data from different sources

Created on 2021-09-22 by the reprex package (v2.0.0)

Session Info
- Session info -----------------------------------------------------------------
 setting  value                       
 version  R version 4.0.2 (2020-06-22)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/Phoenix             
 date     2021-09-22                  

- Packages ---------------------------------------------------------------------
 ! package        * version  date       lib source                         
   abind            1.4-5    2016-07-21 [1] CRAN (R 4.0.0)                 
   assertthat       0.2.1    2019-03-21 [1] CRAN (R 4.0.2)                 
   backports        1.2.1    2020-12-09 [1] CRAN (R 4.0.3)                 
   base64enc        0.1-3    2015-07-28 [1] CRAN (R 4.0.0)                 
   bayesplot        1.8.0    2021-01-10 [1] CRAN (R 4.0.3)                 
   boot             1.3-25   2020-04-26 [2] CRAN (R 4.0.2)                 
   bridgesampling   1.0-0    2020-02-26 [1] CRAN (R 4.0.2)                 
   brms             2.15.0   2021-03-14 [1] CRAN (R 4.0.4)                 
   Brobdingnag      1.2-6    2018-08-13 [1] CRAN (R 4.0.0)                 
   cachem           1.0.4    2021-02-13 [1] CRAN (R 4.0.4)                 
   callr            3.7.0    2021-04-20 [1] CRAN (R 4.0.5)                 
   cli              2.3.1    2021-02-23 [1] CRAN (R 4.0.4)                 
   clipr            0.7.1    2020-10-08 [1] CRAN (R 4.0.3)                 
   coda             0.19-4   2020-09-30 [1] CRAN (R 4.0.2)                 
   codetools        0.2-16   2018-12-24 [2] CRAN (R 4.0.2)                 
   colorspace       2.0-0    2020-11-11 [1] CRAN (R 4.0.3)                 
   colourpicker     1.1.0    2020-09-14 [1] CRAN (R 4.0.2)                 
   conditionz       0.1.0    2019-04-24 [1] CRAN (R 4.0.2)                 
   crayon           1.4.1    2021-02-08 [1] CRAN (R 4.0.2)                 
   crosstalk        1.1.1    2021-01-12 [1] CRAN (R 4.0.3)                 
   crul             1.1.0    2021-02-15 [1] CRAN (R 4.0.4)                 
   curl             4.3      2019-12-02 [1] CRAN (R 4.0.2)                 
   data.table       1.13.6   2020-12-30 [1] CRAN (R 4.0.3)                 
   DBI              1.1.1    2021-01-15 [1] CRAN (R 4.0.3)                 
   desc             1.3.0    2021-03-05 [1] CRAN (R 4.0.4)                 
   devtools         2.3.2    2020-09-18 [1] CRAN (R 4.0.2)                 
   digest           0.6.27   2020-10-24 [1] CRAN (R 4.0.3)                 
   dplyr          * 1.0.4    2021-02-02 [1] CRAN (R 4.0.3)                 
   DT               0.17     2021-01-06 [1] CRAN (R 4.0.3)                 
   dygraphs         1.1.1.6  2018-07-11 [1] CRAN (R 4.0.2)                 
   ellipsis         0.3.1    2020-05-15 [1] CRAN (R 4.0.2)                 
   evaluate         0.14     2019-05-28 [1] CRAN (R 4.0.2)                 
   fansi            0.4.2    2021-01-15 [1] CRAN (R 4.0.3)                 
   farver           2.1.0    2021-02-28 [1] CRAN (R 4.0.4)                 
   fastmap          1.1.0    2021-01-25 [1] CRAN (R 4.0.3)                 
   fs               1.5.0    2020-07-31 [1] CRAN (R 4.0.3)                 
   gamm4            0.2-6    2020-04-03 [1] CRAN (R 4.0.3)                 
   generics         0.1.0    2020-10-31 [1] CRAN (R 4.0.3)                 
   ggplot2          3.3.3    2020-12-30 [1] CRAN (R 4.0.3)                 
   ggridges         0.5.3    2021-01-08 [1] CRAN (R 4.0.3)                 
   glue             1.4.2    2020-08-27 [1] CRAN (R 4.0.2)                 
   gridExtra        2.3      2017-09-09 [1] CRAN (R 4.0.2)                 
   gtable           0.3.0    2019-03-25 [1] CRAN (R 4.0.2)                 
   gtools           3.8.2    2020-03-31 [1] CRAN (R 4.0.0)                 
   highr            0.8      2019-03-20 [1] CRAN (R 4.0.2)                 
   htmltools        0.5.1.1  2021-01-22 [1] CRAN (R 4.0.3)                 
   htmlwidgets      1.5.3    2020-12-10 [1] CRAN (R 4.0.3)                 
   httpcode         0.3.0    2020-04-10 [1] CRAN (R 4.0.2)                 
   httpuv           1.5.5    2021-01-13 [1] CRAN (R 4.0.3)                 
   httr             1.4.2    2020-07-20 [1] CRAN (R 4.0.2)                 
   igraph           1.2.6    2020-10-06 [1] CRAN (R 4.0.3)                 
   inline           0.3.17   2020-12-01 [1] CRAN (R 4.0.2)                 
   jsonlite         1.7.2    2020-12-09 [1] CRAN (R 4.0.3)                 
   knitr            1.31     2021-01-27 [1] CRAN (R 4.0.3)                 
   labeling         0.4.2    2020-10-20 [1] CRAN (R 4.0.2)                 
   later            1.1.0.1  2020-06-05 [1] CRAN (R 4.0.2)                 
   lattice          0.20-41  2020-04-02 [2] CRAN (R 4.0.2)                 
   lazyeval         0.2.2    2019-03-15 [1] CRAN (R 4.0.2)                 
   leaflet          2.0.4.1  2021-01-07 [1] CRAN (R 4.0.5)                 
   lifecycle        1.0.0    2021-02-15 [1] CRAN (R 4.0.4)                 
   lme4             1.1-26   2020-12-01 [1] CRAN (R 4.0.3)                 
   loo              2.4.1    2020-12-09 [1] CRAN (R 4.0.3)                 
   lubridate        1.7.9.2  2020-11-13 [1] CRAN (R 4.0.3)                 
   magrittr         2.0.1    2020-11-17 [1] CRAN (R 4.0.3)                 
   mapproj          1.2.7    2020-02-03 [1] CRAN (R 4.0.2)                 
   mapr           * 0.5.2    2020-10-12 [1] CRAN (R 4.0.5)                 
   maps             3.3.0    2018-04-03 [1] CRAN (R 4.0.2)                 
   markdown         1.1      2019-08-07 [1] CRAN (R 4.0.2)                 
   MASS             7.3-51.6 2020-04-26 [2] CRAN (R 4.0.2)                 
   Matrix           1.2-18   2019-11-27 [2] CRAN (R 4.0.2)                 
   matrixStats      0.58.0   2021-01-29 [1] CRAN (R 4.0.3)                 
   memoise          2.0.0    2021-01-26 [1] CRAN (R 4.0.3)                 
   mgcv             1.8-31   2019-11-09 [2] CRAN (R 4.0.2)                 
   mime             0.9      2020-02-04 [1] CRAN (R 4.0.0)                 
   miniUI           0.1.1.1  2018-05-18 [1] CRAN (R 4.0.2)                 
   minqa            1.2.4    2014-10-09 [1] CRAN (R 4.0.2)                 
   munsell          0.5.0    2018-06-12 [1] CRAN (R 4.0.2)                 
   mvtnorm          1.1-1    2020-06-09 [1] CRAN (R 4.0.0)                 
   nlme             3.1-148  2020-05-24 [2] CRAN (R 4.0.2)                 
   nloptr           1.2.2.2  2020-07-02 [1] CRAN (R 4.0.2)                 
   oai              0.3.0    2019-09-07 [1] CRAN (R 4.0.2)                 
   pillar           1.5.1    2021-03-05 [1] CRAN (R 4.0.4)                 
   pkgbuild         1.2.0    2020-12-15 [1] CRAN (R 4.0.3)                 
   pkgconfig        2.0.3    2019-09-22 [1] CRAN (R 4.0.2)                 
   pkgload          1.2.0    2021-02-23 [1] CRAN (R 4.0.4)                 
   plyr             1.8.6    2020-03-03 [1] CRAN (R 4.0.2)                 
   prettyunits      1.1.1    2020-01-24 [1] CRAN (R 4.0.2)                 
   processx         3.5.2    2021-04-30 [1] CRAN (R 4.0.5)                 
   projpred         2.0.2    2020-10-28 [1] CRAN (R 4.0.3)                 
   promises         1.2.0.1  2021-02-11 [1] CRAN (R 4.0.4)                 
   ps               1.6.0    2021-02-28 [1] CRAN (R 4.0.4)                 
   purrr            0.3.4    2020-04-17 [1] CRAN (R 4.0.2)                 
   R6               2.5.0    2020-10-28 [1] CRAN (R 4.0.3)                 
   rbison           1.0.0    2020-06-08 [1] CRAN (R 4.0.2)                 
   RColorBrewer     1.1-2    2014-12-07 [1] CRAN (R 4.0.0)                 
   Rcpp             1.0.7    2021-07-07 [1] CRAN (R 4.0.5)                 
 D RcppParallel     5.1.4    2021-05-04 [1] CRAN (R 4.0.5)                 
 V rebird           1.2.0    2021-09-20 [1] CRAN (R 4.0.5)                 
   remotes          2.2.0    2020-07-21 [1] CRAN (R 4.0.2)                 
   reprex         * 2.0.0    2021-04-02 [1] CRAN (R 4.0.5)                 
   reshape2         1.4.4    2020-04-09 [1] CRAN (R 4.0.2)                 
 V rgbif            3.5.2    2021-06-02 [1] CRAN (R 4.0.5)                 
   rgdal            1.5-23   2021-02-03 [1] CRAN (R 4.0.3)                 
   ridigbio         0.3.5    2017-02-16 [1] CRAN (R 4.0.2)                 
   rlang            0.4.10   2020-12-30 [1] CRAN (R 4.0.3)                 
   rmarkdown        2.7      2021-02-19 [1] CRAN (R 4.0.4)                 
   rprojroot        2.0.2    2020-11-15 [1] CRAN (R 4.0.3)                 
   rsconnect        0.8.16   2019-12-13 [1] CRAN (R 4.0.2)                 
   rstan            2.21.2   2020-07-27 [1] CRAN (R 4.0.2)                 
   rstantools       2.1.1    2020-07-06 [1] CRAN (R 4.0.4)                 
   rstudioapi       0.13     2020-11-12 [1] CRAN (R 4.0.3)                 
 V rvertnet         0.8.0    2021-05-13 [1] CRAN (R 4.0.5)                 
   scales           1.1.1    2020-05-11 [1] CRAN (R 4.0.2)                 
   sessioninfo      1.1.1    2018-11-05 [1] CRAN (R 4.0.2)                 
   shiny            1.6.0    2021-01-25 [1] CRAN (R 4.0.3)                 
   shinyjs          2.0.0    2020-09-09 [1] CRAN (R 4.0.2)                 
   shinystan        2.5.0    2018-05-01 [1] CRAN (R 4.0.3)                 
   shinythemes      1.2.0    2021-01-25 [1] CRAN (R 4.0.3)                 
   sp               1.4-5    2021-01-10 [1] CRAN (R 4.0.3)                 
   spocc          * 1.2.0.91 2021-09-23 [1] Github (ropensci/spocc@1deb001)
   StanHeaders      2.21.0-7 2020-12-17 [1] CRAN (R 4.0.2)                 
   statmod          1.4.35   2020-10-19 [1] CRAN (R 4.0.2)                 
   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.2)                 
   styler           1.3.2    2020-02-23 [1] CRAN (R 4.0.2)                 
   testthat         3.0.2    2021-02-14 [1] CRAN (R 4.0.4)                 
   threejs          0.3.3    2020-01-21 [1] CRAN (R 4.0.2)                 
   tibble           3.1.0    2021-02-25 [1] CRAN (R 4.0.4)                 
   tidyselect       1.1.0    2020-05-11 [1] CRAN (R 4.0.2)                 
   triebeard        0.3.0    2016-08-04 [1] CRAN (R 4.0.2)                 
   urltools         1.7.3    2019-04-14 [1] CRAN (R 4.0.2)                 
   usethis          2.0.1    2021-02-10 [1] CRAN (R 4.0.2)                 
   utf8             1.2.1    2021-03-12 [1] CRAN (R 4.0.5)                 
   uuid             0.1-4    2020-02-26 [1] CRAN (R 4.0.0)                 
   V8               3.4.0    2020-11-04 [1] CRAN (R 4.0.3)                 
   vctrs            0.3.6    2020-12-17 [1] CRAN (R 4.0.3)                 
   wellknown        0.7.2    2021-01-07 [1] CRAN (R 4.0.3)                 
   whisker          0.4      2019-08-28 [1] CRAN (R 4.0.2)                 
   withr            2.4.1    2021-01-26 [1] CRAN (R 4.0.3)                 
   wk               0.4.1    2021-03-16 [1] CRAN (R 4.0.4)                 
   xfun             0.20     2021-01-06 [1] CRAN (R 4.0.3)                 
   xml2             1.3.2    2020-04-23 [1] CRAN (R 4.0.2)                 
   xtable           1.8-4    2019-04-21 [1] CRAN (R 4.0.2)                 
   xts              0.12.1   2020-09-09 [1] CRAN (R 4.0.2)                 
   yaml             2.2.1    2020-02-01 [1] CRAN (R 4.0.2)                 
   zoo              1.8-8    2020-05-02 [1] CRAN (R 4.0.2)                 

[1] C:/Users/David/Documents/lib/R
[2] C:/Program Files/R/R-4.0.2/library

 V -- Loaded and on-disk version mismatch.
 D -- DLL MD5 mismatch, broken installation.
@AMBarbosa
Copy link

I too have noticed this problem after downloading data from different sources and converting with occ2df(), where longitude and latitude are included as character (so they can't directly be plotted on a map):

spocc_dat <- occ("Daboia mauritanica", from = c("gbif", "inat", "vertnet"))
spocc_df <- occ2df(spocc_dat)
str(spocc_df)
# [. . .]
# $ longitude: chr [1:178] "5.476839" "-8.226904" "-6.620554" "3.69187" ...
# $ latitude : chr [1:178] "36.121235" "31.685136" "33.87562" "32.443245" ...
# [. . .]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants