# NOT RUN {
# BEWARE: this may error for you with a message like
# "GeomRasterAnn was built with an incompatible version of ggproto".
# This is fixed in the dev version of `ggmap`, but not in the CRAN
# version. Apologies for the problem.
## spocc
library("spocc")
gd <- occ(query = 'Accipiter striatus', from = 'gbif', limit=75,
has_coords = TRUE)
map_ggmap(gd)
map_ggmap(gd$gbif)
## rgbif
library("rgbif")
### occ_search() output
res <- occ_search(scientificName = "Puma concolor", limit = 100)
map_ggmap(res)
### occ_data() output
res <- occ_data(scientificName = "Puma concolor", limit = 100)
map_ggmap(res)
#### many taxa
res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"),
limit = 30)
map_ggmap(res)
## data.frame
df <- data.frame(name = c('Poa annua', 'Puma concolor', 'Foo bar'),
longitude = c(-120, -121, -123),
latitude = c(41, 42, 45), stringsAsFactors = FALSE)
map_ggmap(df)
### usage of occ2sp()
#### SpatialPointsDataFrame
spdat <- occ2sp(gd)
map_ggmap(spdat)
# many species, each gets a different color
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 30, has_coords = TRUE,
gbifopts = list(country = 'US'))
map_ggmap(dat)
map_ggmap(dat, zoom = 5)
map_ggmap(dat, color = '#6B944D')
map_ggmap(dat, color = c('#976AAE', '#6B944D', '#BD5945'))
# }
Run the code above in your browser using DataLab