occmap: Map species occurrences

Description Usage Arguments Details Value Examples

View source: R/occmap.R

Description

Plot map of species occurrences (or any set of georeferenced points) on top of different background layers.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
occmap(
  locs,
  ras = NULL,
  bg = "ggmap",
  proj = "+init=epsg:4326",
  pcol = "red",
  alpha = 1,
  psize = 1,
  add = FALSE,
  leaflet.base = NULL,
  mapmisc_server = "maptoolkit",
  filename = "occmap.kmz",
  ...
)

Arguments

locs

A matrix, dataframe, SpatialPoints or SpatialPointsDataFrame containing coordinates of species occurrences. If locs is a matrix or dataframe, it will be converted to a spatial object using locs2sp.

ras

Raster* object to be used as background for points. Default is NULL, in which case a background map defined by bg will be used.

bg

Type of background map. Either 'google' for Google maps background (using gmap) (note this requires a Google API key - currently not working!), 'coast' for coastlines (using coastsCoarse from rworldmap package), 'ggmap' for maps provided by get_map in ggmap package, 'leaflet' for an interactive HTML map using leaflet, 'mapmisc' for using any of the layers available in mapmisc package, or 'kml' for producing a KMZ file to be opened with Google Earth.

proj

Character string specifying the projection of coordinates data (see proj4string or http://spatialreference.org). Default is geographic (unprojected) coordinates, datum WGS84. Not used if locs is already an Spatial object with defined projection.

pcol

Colour to be used for points. Default is "red".

alpha

Colour transparency for points, between 0 (fully transparent) and 1 (fully opaque).

psize

Point size. Default is 1 (cex = 1).

add

Logical. Add these occurrences to a previous map? (e.g. for a new species). Default is FALSE. Note this feature doesn't work for all map types. For leaflet maps, when add = TRUE, a leaflet basemap (e.g. as produced by a previous call to occmap) must be provided (see leaflet.base).

leaflet.base

Leaflet map to be used as basemap to add further points when add is TRUE.

mapmisc_server

character. Server/type of background map to be used when bg = "mapmisc". Run osmTiles to see all the available layers.

filename

Character. Path and filename of the KMZ file produced when bg = "kml".

...

additional parameters to be passed to dismo::gmap if bg == 'google' plot if bg == 'coast' ggmap::get_map if bg == 'ggmap' leafletR::leaflet if bg == 'leaflet' raster::plot or raster::plotRGB if bg == 'mapmisc' See these functions help files for details.

Details

If using ggmap and stamen maps, large regions seem to give problems.

Value

A map (plot), unless bg = 'KML' in which case a kmz file is saved to be explored with Google Earth. In some cases, a raster layer, leaflet object, or ggplot object is returned in addition to the 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
28
29
30
31
32
33
34
35
36
37
## Not run: 
# Using acaule dataset from dismo package:
library(dismo)
data(acaule)

occmap(locs = acaule)  # If 'ras' not provided, default is bg = "ggmap"
occmap(acaule, bg = "coast")  # just coastlines as background map
occmap(acaule, bg = "leaflet") # leaflet interactive map

# Watercolor map from Stamen using ggmap
# NB: use small regions, otherwise give error to download map tiles
locs_redux <- subset(acaule, lon > -80 & lon < -60 & lat > -30 & lat < -10)
occmap(locs = locs_redux, maptype = 'watercolor', source = 'stamen',
           pcol = "darkgreen", psize = 4)

# Plot occurrences in a specific country:
occmap(locs = subset(acaule, country=="Bolivia"), bg = "leaflet")
# (note there are georeferencing errors in the data)


# Add transparency to points
occmap(locs = acaule, pcol = "red", alpha = 0.5, bg = "coast")
occmap(locs = acaule, pcol = "red", alpha = 0.5, bg = "leaflet")


## Providing spatial objects ##
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
occmap(meuse)

#alternatively, provide projection argument:
data(meuse)
coordinates(meuse) <- ~x+y
occmap(meuse, proj = "+init=epsg:28992")

## End(Not run)

Pakillo/rSDM documentation built on Oct. 15, 2020, 3:20 a.m.