get_smarter_geojson | R Documentation |
Fetch SMARTER REST API samples with GPS coordinates and return them into as simple features.
get_smarter_geojson(species, query = list(), polygons = NULL)
species |
a smarter species ("Goat", "Sheep") |
query |
a |
polygons |
a sf object with polygons to filter the samples |
a sf data object
## Not run:
# required to execute pipe operations and draw examples
library(dplyr)
library(leaflet)
# get goat samples with GPS coordinates as sf object
goat_data <- get_smarter_geojson(
species = "Goat",
query = list(
type = "background",
country = "Italy"
)
)
# leaflet doesn't handle MULTIPOINT data (https://github.com/rstudio/leaflet/issues/352)
# Cast them into point considering only the first objects
# (https://r-spatial.github.io/sf/reference/st_cast.html)
goat_data <- goat_data %>% sf::st_cast("POINT", do_split=FALSE)
# draw samples in a leaflet map using markerCluser
leaflet(data = goat_data) %>%
leaflet::addTiles() %>%
leaflet::addMarkers(
clusterOptions = leaflet::markerClusterOptions(), label = ~smarter_id
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.