get_smarter_geojson | R Documentation |
Fetch SMARTER REST API samples with GPS coordinates and return them into as
simple features.
Cached token is used or a new token is generated if not provided when calling
this function (see get_smarter_token
for more information)
get_smarter_geojson(species, query = list(), token = NULL)
species |
a smarter species ("Goat", "Sheep") |
query |
a |
token |
a string with a valid token |
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.