Description Usage Arguments Details Value Examples
Plot map of species occurrences (or any set of georeferenced points) on top of different background layers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 |
ras |
Raster* object to be used as background for points. Default is NULL, in which case a background map defined by |
bg |
Type of background map. Either
'google' for Google maps background (using |
proj |
Character string specifying the projection of coordinates data (see |
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 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 |
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. |
If using ggmap and stamen maps, large regions seem to give problems.
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.