# \donttest{
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()
# }
Run the code above in your browser using DataLab