Learn R Programming

mapr (version 0.4.0)

map_ggmap: ggpmap visualization of species occurences

Description

ggpmap visualization of species occurences

Usage

map_ggmap(x, zoom = 3, point_color = "#86161f", color = NULL, size = 3,
  lon = "longitude", lat = "latitude", maptype = "terrain",
  source = "google", ...)

Arguments

x

The data. An object of class occdat, occdatind, gbif, gbif_data, SpatialPoints, SpatialPointsDataFrame, or data.frame. The package spocc needed for the first two, and rgbif needed for the third. When data.frame input, any number of columns allowed, but with at least the following: name (the taxonomic name), latitude (in dec. deg.), longitude (in dec. deg.)

zoom

zoom level for map. Adjust depending on how your data look.

point_color

Default color of your points. Deprecated, use color

color

Default color of your points.

size

point size, Default: 3

lon, lat

(character) Longitude and latitude variable names. Ignored unless data.frame input to x parameter. We attempt to guess, but if nothing close, we stop. Default: longitude and latitude

maptype

(character) map theme. see get_map in ggmap for options. Default: none

source

(character) Google Maps ("google"), OpenStreetMap ("osm"), Stamen Maps ("stamen"), or CloudMade maps ("cloudmade"). Default: osm

...

Ignored

Details

Does not support adding a convex hull via hull()

Examples

Run this code
# 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