gbifmap: Make a map to visualize GBIF occurrence data.

Description Usage Arguments Details Value Examples

View source: R/gbifmap.r

Description

Make a map to visualize GBIF occurrence data.

Usage

1
2
gbifmap(input = NULL, mapdatabase = "world", region = ".",
  geom = geom_point, jitter = NULL, customize = NULL)

Arguments

input

Either a single data.frame or a list of data.frame's (e.g., from different speies). The data.frame has to have, in addition to any other columns, columns named exactly "decimalLatitude" and "decimalLongitude".

mapdatabase

The map database to use in mapping. What you choose here determines what you can choose in the region parameter. One of: county, state, usa, world, world2, france, italy, or nz.

region

The region of the world to map. Run sort(unique(ggplot2::map_data("world")$region)) to see region names for the world database layer, or sort(unique(ggplot2::map_data("state")$region)) for the state layer.

geom

The geom to use, one of geom_point or geom_jitter. Don't quote them.

jitter

If you use jitterposition, the amount by which to jitter points in width, height, or both.

customize

Further arguments passed on to ggplot.

Details

gbifmap takes care of cleaning up the data.frame (removing NA's, etc.) returned from rgbif functions, and creating the map. This function gives a simple map of your data. You can look at the code behing the function itself if you want to build on it to make a map according to your specfications.

Note that this function removes values that are impossible on the globe, and those rows that have both lat and long as NA or zeros.

Value

Map (using ggplot2 package) of points on a map or tiles on a map.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
# Make a map of Puma concolor occurrences
key <- name_backbone(name='Puma concolor')$speciesKey
dat <- occ_search(taxonKey=key, return='data', limit=100)
gbifmap(dat)

# Plot more Puma concolor occurrences
dat <- occ_search(taxonKey=key, return='data', limit=1200)
nrow(dat)
gbifmap(dat)

# Jitter positions, compare the two
library("ggplot2")
gbifmap(dat)
gbifmap(dat, geom = geom_jitter, jitter = position_jitter(1, 6))

# many species
splist <- c('Cyanocitta stelleri', 'Junco hyemalis', 'Aix sponsa')
keys <- vapply(splist, function(x) name_suggest(x)$key[1], numeric(1),
  USE.NAMES=FALSE)
dat <- occ_data(keys, limit = 50)
library("data.table")
dd <- rbindlist(lapply(dat, function(z) z$data), fill = TRUE,
  use.names = TRUE)
gbifmap(dd)

## End(Not run)

rgbif documentation built on May 30, 2017, 5:39 a.m.

Search within the rgbif package
Search all R packages, documentation and source code