Last active
May 11, 2023 17:35
-
-
Save cboettig/c3205d798d086e6fdcfe9dce34ec9d8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rstac) | |
library(gdalcubes) | |
# let's pick some spatial extent, say, a bbox around "India" | |
loc <- spData::world |> dplyr::filter(name_long == "India") | |
box <- sf::st_bbox(loc) | |
matches <- | |
stac("https://planetarycomputer.microsoft.com/api/stac/v1") |> | |
stac_search(collections = "io-biodiversity", | |
bbox = c(box), | |
limit = 1000) |> | |
post_request() |> | |
items_sign(sign_fn = sign_planetary_computer()) | |
length(matches$features) # 92 seperate assets we will stitch together! | |
cube <- gdalcubes::stac_image_collection(matches$features, asset_names = "data") | |
v <- cube_view(srs = "EPSG:4326", | |
extent = list(t0 = "2017-01-01", t1 = "2020-12-31", | |
left = box[1], right = box[3], | |
top = box[4], bottom = box[2]), | |
nx = 500, ny=500, nt = "P1Y") | |
Q <- raster_cube(cube,v) | |
plot(Q, col = viridisLite::magma) | |
# animate | |
animate(Q, col = viridisLite::mako, key.pos = 1, save_as = "anim.gif", fps = 1) | |
Author
cboettig
commented
May 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment