occmap | R Documentation |
Plot map of species occurrences (or any set of point coordinates) on top of different background layers.
occmap(
locs,
ras = NULL,
bg = "Esri.WorldImagery",
type = c("base", "ggplot", "leaflet"),
pcol = "red",
alpha = 1,
psize = 1,
add = FALSE,
prev.map = NULL,
...
)
locs |
An |
ras |
A |
bg |
Character. Type of background map to be used if |
type |
Character. One of "base", "ggplot" or "leaflet" to define the type of map produced. |
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 |
prev.map |
Map to be used as basemap to add further points (only applicable for "leaflet" and "ggplot" map types). |
... |
additional parameters to be passed to
|
A map plus a leaflet or ggplot object, depending on type
.
## Example coordinates
locs <- data.frame(lon = c(-5.8, -5.5, -5.9), lat = c(35.7, 36.2, 36.5))
locs <- locs2sf(locs, crs = 4326)
## Default map
occmap(locs, psize = 6)
occmap(locs, psize = 6, bg = "CartoDB.Positron") # Change background
## Interactive (leaflet) map
occmap(locs, psize = 6, type = "leaflet")
occmap(locs, psize = 6, type = "leaflet", bg = "CartoDB.Positron")
## ggplot map
occmap(locs, psize = 6, type = "ggplot")
## Adding points to a previous map
new.locs <- data.frame(lon = c(-5.8, -5.4), lat = c(36.2, 36.5))
new.locs.sf <- locs2sf(new.locs, crs = 4326)
## base
map <- occmap(locs, psize = 6)
occmap(new.locs.sf, add = TRUE, psize = 6, pcol = "blue")
## Adding points to a previous map (leaflet)
map <- occmap(locs, psize = 6, type = "leaflet")
occmap(new.locs.sf, prev.map = map, psize = 6, pcol = "blue")
## Adding points to a previous map (ggplot)
map <- occmap(locs, psize = 6, type = "ggplot")
occmap(new.locs.sf, prev.map = map, psize = 6, pcol = "blue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.