Description Usage Arguments Details Value Examples
Make interactive maps with Leaflet.js
1 2 3 4 5 6 7 8 9 | map_leaflet(
x,
lon = "longitude",
lat = "latitude",
color = NULL,
size = 13,
name = NULL,
...
)
|
x |
The data. An object of class |
lon, lat |
(character) Longitude and latitude variable names. Ignored
unless |
color |
Default color of your points. |
size |
point size, Default: 13 |
name |
(character) the column name that contains the name to use in
creating the map. If left |
... |
Ignored |
We add popups by default, and add all columns to the popup. The
html is escaped with htmltools::htmlEscape()
a Leaflet map in Viewer in Rstudio, or in your default browser otherwise
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | ## Not run:
## spocc
library("spocc")
(out <- occ(query='Accipiter striatus', from='gbif', limit=50,
has_coords=TRUE))
### with class occdat
map_leaflet(out)
### with class occdatind
map_leaflet(out$gbif)
### use occ2sp
map_leaflet(occ2sp(out))
## rgbif
if (requireNamespace("rgbif")) {
library("rgbif")
res <- occ_search(scientificName = "Puma concolor", limit = 100)
map_leaflet(res)
}
## SpatialPoints class
library("sp")
df <- data.frame(longitude = c(-120,-121),
latitude = c(41, 42), stringsAsFactors = FALSE)
x <- SpatialPoints(df)
map_leaflet(x)
## SpatialPointsDataFrame class
if (requireNamespace("rgbif")) {
library("rgbif")
### occ_search() output
res <- occ_search(scientificName = "Puma concolor", limit = 100)
x <- res$data
library("sp")
x <- x[stats::complete.cases(x$decimalLatitude, x$decimalLongitude), ]
coordinates(x) <- ~decimalLongitude+decimalLatitude
map_leaflet(x)
### occ_data() output
res <- occ_data(scientificName = "Puma concolor", limit = 100)
map_leaflet(res)
}
#### many taxa
res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"),
limit = 30)
res
map_leaflet(res)
## data.frame
df <- data.frame(name = c('Poa annua', 'Puma concolor'),
longitude = c(-120,-121),
latitude = c(41, 42), stringsAsFactors = FALSE)
map_leaflet(df)
# many species
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 50, has_coords = TRUE)
map_leaflet(dat)
map_leaflet(dat, color = c('#AFFF71', '#AFFF71', '#AFFF71'))
map_leaflet(dat, color = c('#976AAE', '#6B944D', '#BD5945'))
# add a convex hull
## map_leaflet(dat) %>% hull() # using pipes
hull(map_leaflet(dat))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.