coverage_fraction: Compute the fraction of raster cells covered by a polygon

coverage_fractionR Documentation

Compute the fraction of raster cells covered by a polygon

Description

Compute the fraction of raster cells covered by a polygon

Usage

## S4 method for signature 'RasterLayer,sf'
coverage_fraction(x, y, crop = FALSE)

## S4 method for signature 'RasterLayer,sfc_MULTIPOLYGON'
coverage_fraction(x, y, crop)

## S4 method for signature 'RasterLayer,sfc_POLYGON'
coverage_fraction(x, y, crop)

## S4 method for signature 'SpatRaster,sf'
coverage_fraction(x, y, crop = FALSE)

## S4 method for signature 'SpatRaster,sfc_MULTIPOLYGON'
coverage_fraction(x, y, crop)

## S4 method for signature 'SpatRaster,sfc_POLYGON'
coverage_fraction(x, y, crop)

Arguments

x

a (possibly empty) RasterLayer whose resolution and extent will be used for the generated RasterLayer.

y

a sf object with polygonal geometries

crop

if TRUE, each generated RasterLayer will be cropped to the extent of its associated feature.

Value

a list with a RasterLayer for each feature in y. Values of the raster represent the fraction of each cell in x that is covered by y.

Examples

rast <- raster::raster(matrix(1:100, ncol=10), xmn=0, ymn=0, xmx=10, ymx=10)
poly <- sf::st_as_sfc('POLYGON ((2 2, 7 6, 4 9, 2 2))')

cov_frac <- coverage_fraction(rast, poly)[[1]]

exactextractr documentation built on Sept. 20, 2023, 9:08 a.m.