library(rstac)
library(gdalcubes)
library(stars)
library(tmap)
library(dplyr)
4: Biodiversity Intactness Index
library(spData)
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source')`
<- spData::us_states |> filter(NAME=="California") |> st_bbox() box_ca
<- c(xmin=-123, ymin=37, xmax=-121, ymax=39)
box <- c(box_ca)
box <-
items stac("https://planetarycomputer.microsoft.com/api/stac/v1") |>
stac_search(collections = "io-biodiversity",
bbox = box,
limit = 100) |>
post_request() |>
items_sign(sign_planetary_computer())
<- stac_image_collection(items$features, asset_names = c("data"))
col
<- cube_view(srs ="EPSG:4326",
cube extent = list(t0 = "2017-01-01", t1 = "2017-12-31",
left = box[1], right = box[3],
top = box[4], bottom = box[2]),
dx = 0.005, dy = 0.005, dt = "P1Y")
<- raster_cube(col, cube) data
<- data |> slice_time("2017-01-01") |> st_as_stars()
bii tm_shape(bii) + tm_raster()
stars object downsampled to 1028 by 948 cells.