View source: R/build_aggregation_table.R
build_aggregation_table | R Documentation |
Build a table to quickly aggregate from pixels to polygons
build_aggregation_table(polygons, id_raster, polygon_id_field, verbose = FALSE)
polygons |
terra::SpatVector object. Should contain a unique ID field. |
id_raster |
terra::SpatRaster object. ID raster created by |
polygon_id_field |
( |
verbose |
( |
data.table with fields:
polygon_id: Unique polygon identifier
pixel_id: unique pixel ID from the ID raster
masked_pixel_id: Index counting only non-NA pixels from the ID raster
area_fraction: fraction of the pixel area falling within this polygon
Merged fields from the table of polygons
calculate_pixel_fractions_single_polygon()
## Not run:
polygons <- sf::st_read(system.file('extdata/Benin_communes.gpkg', package = 'mbg'))
id_raster <- build_id_raster(polygons)
aggregation_table <- build_aggregation_table(
polygons, id_raster, polygon_id_field = 'commune_code'
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.