Skip to content

Instantly share code, notes, and snippets.

@DDorch
DDorch / aggregate.stars-example.R
Last active October 25, 2023 13:31
Spatial aggregation containing NA values with stars R package
library(stars)
# USA states
nc = sf::read_sf(system.file("gpkg/nc.gpkg", package = "sf"), "nc.gpkg")
nc = st_transform(nc, "OGC:CRS84")
# Coarse grid upon the map
bb <- as.list(round(st_bbox(nc)))
x <- seq(bb$xmin, bb$xmax)
y <- seq(bb$ymin, bb$ymax)