# NOT RUN {
## spocc
library("spocc")
(out <- occ(query='Accipiter striatus', from='gbif', limit=50,
has_coords=TRUE))
### with class occdat
map_leaflet(out)
### with class occdatind
map_leaflet(out$gbif)
### use occ2sp
map_leaflet(occ2sp(out))
## rgbif
if (requireNamespace("rgbif")) {
library("rgbif")
res <- occ_search(scientificName = "Puma concolor", limit = 100)
map_leaflet(res)
}
## SpatialPoints class
library("sp")
df <- data.frame(longitude = c(-120,-121),
latitude = c(41, 42), stringsAsFactors = FALSE)
x <- SpatialPoints(df)
map_leaflet(x)
## SpatialPointsDataFrame class
if (requireNamespace("rgbif")) {
library("rgbif")
### occ_search() output
res <- occ_search(scientificName = "Puma concolor", limit = 100)
x <- res$data
library("sp")
x <- x[stats::complete.cases(x$decimalLatitude, x$decimalLongitude), ]
coordinates(x) <- ~decimalLongitude+decimalLatitude
map_leaflet(x)
### occ_data() output
res <- occ_data(scientificName = "Puma concolor", limit = 100)
map_leaflet(res)
}
#### many taxa
res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"),
limit = 30)
res
map_leaflet(res)
## data.frame
df <- data.frame(name = c('Poa annua', 'Puma concolor'),
longitude = c(-120,-121),
latitude = c(41, 42), stringsAsFactors = FALSE)
map_leaflet(df)
# many species
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 50, has_coords = TRUE)
map_leaflet(dat)
map_leaflet(dat, color = c('#AFFF71', '#AFFF71', '#AFFF71'))
map_leaflet(dat, color = c('#976AAE', '#6B944D', '#BD5945'))
# add a convex hull
## map_leaflet(dat) %>% hull() # using pipes
hull(map_leaflet(dat))
# }
Run the code above in your browser using DataLab