Takes a named list of SpatRaster objects (one per year, as returned by
ntl_download() or bhuvan_raster()) and an sf or SpatVector polygon
layer, and returns a tidy long-format data frame with one row per
region per year.
Arguments
- rasters
A named list of
SpatRasterobjects. Names should be years (e.g.,"2020","2021"). Returned byntl_download()orbhuvan_raster().- polygons
An
sfobject orSpatVectorcontaining the regions to summarise over.- fun
Aggregation function name passed to
terra::zonal(). Default"mean". Also accepts"sum","median", etc.- id_col
Name of the column in
polygonsto use asregion_id. IfNULL(default), the first character column is used.
Value
A data frame with columns:
- region_id
Character. Region identifier from
polygons.- year
Integer. Year, taken from the name of each raster.
- mean_radiance
Numeric. Aggregated radiance value.
- n_pixels
Integer. Number of non-NA cells contributing to the stat.
Details
The polygons argument accepts any sf object – GADM, bharatviz GeoJSONs,
LGD districts, or any shapefile loaded with sf::read_sf().
Examples
if (FALSE) { # \dontrun{
districts <- sf::read_sf("https://bharatviz.org/India-bhuvan-districts.geojson")
rasters <- bhuvan_raster(districts, years = 2018:2023)
panel <- extract_panel(rasters, districts)
head(panel)
} # }