OpenRange_api_species {OpenRange} | R Documentation |
Download range maps for given species using the API.
Description
OpenRange_api_species downloads range maps for the specified species.
Usage
OpenRange_api_species(species, directory, include_id = TRUE, ...)
Arguments
species |
A single species. |
directory |
Directory that range maps should be saved in. |
include_id |
Logical. Should the range_id be appended to the file name? Needed to save multiple maps per species. |
... |
Additional arguments passed to internal functions. |
Value
NULL. Called for its side effect of downloading range maps.
Note
Details on the construction of BIEN range maps is available at http://bien.nceas.ucsb.edu/bien/biendata/bien-3/
See Also
Other range functions:
OpenRange_api_load_species()
,
OpenRange_get_license()
,
OpenRange_get_stats()
,
OpenRange_list_scenarios()
,
OpenRange_load_species()
,
OpenRange_sf()
,
OpenRange_species()
Examples
library(OpenRange)
library(maps) #a convenient source of maps
library(sf)
library(ggplot2)
# Create temp directory
temp_dir <- file.path(tempdir(), "BIEN_temp")
#Download ranges
OpenRange_api_species(species = "Abies_amabilis",
directory = temp_dir,
include_id = TRUE) # saves ranges to a temporary directory
#Reading files
Abies_poly <- st_read(dsn = temp_dir,
layer = "Abies_amabilis_117684")
# Get a map to plot on
world <- map("world", plot = FALSE, fill = TRUE)|>
st_as_sf()
#Plotting files
ggplot(data = world)+
geom_sf()+
geom_sf(data = Abies_poly,
fill="green")+
coord_sf(xlim = st_bbox(Abies_poly)[c(1,3)],
ylim = st_bbox(Abies_poly)[c(2,4)]) +
theme_bw()
#Getting data from the files
Abies_poly |>
st_drop_geometry()
[Package OpenRange version 0.0.1 Index]