knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(rSDM)
Let's create example point coordinates and convert them to a spatial (sf) object:
locs <- data.frame(lon = c(-5.8, -5.5, -5.9), lat = c(35.7, 36.2, 36.5)) locs <- locs2sf(locs, crs = 4326) locs
Note that SpatVector objects (from terra) are also accepted, and can be created using rSDM::locs2vect()
.
Unless a raster ras
is provided, occmap
will automatically download a background map from the internet.
occmap(locs, psize = 6)
The background map can be easily changed using the bg
argument:
occmap(locs, psize = 6, bg = "CartoDB.Positron")
occmap(locs, psize = 6, type = "leaflet") occmap(locs, psize = 6, type = "leaflet", bg = "CartoDB.Positron")
occmap(locs, psize = 6, type = "ggplot")
Let's create some new coordinates (e.g. for a different species):
new.locs <- data.frame(lon = c(-5.8, -5.4), lat = c(36.2, 36.5)) new.locs.sf <- locs2sf(new.locs, crs = 4326)
Note the add = TRUE
argument:
map <- occmap(locs, psize = 6) occmap(new.locs.sf, add = TRUE, psize = 6, pcol = "blue")
Note the previous map has to be provided (using prev.map
argument):
map <- occmap(locs, psize = 6, type = "leaflet") occmap(new.locs.sf, prev.map = map, psize = 6, pcol = "blue")
Note the previous map has to be provided (using prev.map
argument):
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.