Utilities for 'vizualizing' species occurrence data. Includes functions to 'vizualize' occurrence data from 'spocc', 'rgbif', and other packages. Mapping options included for base R plots, 'ggplot2', and various interactive maps.
Stable version from CRAN
Development version from GitHub
if (!require("devtools")) install.packages("devtools") devtools::install_github("ropensci/mapr")
spp <- c('Danaus plexippus','Accipiter striatus','Pinus contorta') dat <- occ(query = spp, from = 'gbif', has_coords = TRUE, limit = 100) map_leaflet(dat)
You can also create interactive maps via the
mapgist function. You have to have a Github account to use this function. Github accounts are free though, and great for versioning and collaborating on code or papers. When you run the
map_gist function it will ask for your Github username and password. You can alternatively store those in your
.Rprofile file by adding entries for username (
options(github.username = 'username')) and password (
options(github.password = 'password')).
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta') dat <- occ(query = spp, from = 'gbif', has_coords = TRUE, limit = 100) dat <- fixnames(dat) map_gist(dat, color = c("#976AAE", "#6B944D", "#BD5945"))
Base plots, or the built in plotting facility in R accessed via
plot(), is quite fast, but not easy or efficient to use, but are good for a quick glance at some data.
spnames <- c('Accipiter striatus', 'Setophaga caerulescens', 'Spinus tristis') out <- occ(query = spnames, from = 'gbif', has_coords = TRUE, limit = 100) map_plot(out, cex = 1, pch = 10)
ggplot2 is a powerful package for making visualizations in R. Read more about it here.
dat <- occ(query = 'Lynx rufus californicus', from = 'gbif', has_coords = TRUE, limit = 200) map_ggplot(dat, map = "usa")
All functions take the following kinds of inputs:
occdat, from the package
spocc. An object of this class is composed of many objects of class
occdatind, from the package
gbif, from the package
data.frame. This data.frame can have any columns, but must include a column for taxonomic names (e.g.,
name), and for latitude and longitude (we guess your lat/long columns, starting with the default
Scott Chamberlain (2016). mapr: 'Visualize' Species Occurrence Data. R package version 0.2.0. https://cran.rstudio.com/package=mapr