calculate_pixel_fractions_single_polygon {mbg}R Documentation

Calculate fractional pixels in a polygon

Description

Calculate the fraction of each pixel's area that falls within a single polygon

Usage

calculate_pixel_fractions_single_polygon(polygon, id_raster, polygon_id = NULL)

Arguments

polygon

terra::SpatVector object of length 1. The polygon to calculate fractional areas across.

id_raster

terra::SpatRaster object. ID raster created for the set of all polygons to be considered, created by build_id_raster().

polygon_id

(optional). ID for this polygon. Must have length 1.

Details

This is a helper function called by build_aggregation_table().

Value

data.table containing two or three columns:

See Also

build_aggregation_table

Examples

## Not run: 
  polygons <- sf::st_read(system.file('extdata/Benin_communes.gpkg', package = 'mbg'))
  id_raster <- build_id_raster(polygons)
  pixel_fractions <- calculate_pixel_fractions_single_polygon(
    polygon = polygons[1, ], id_raster
  )
  head(pixel_fractions)

## End(Not run)


[Package mbg version 1.1.0 Index]