genericExtract: Generic extract points

View source: R/terra-raster-utils.R

genericExtractR Documentation

Generic extract points

Description

Extracts points from raster layers using the original raster layer projection.

Usage

genericExtract(x, y, field = NULL, ...)

Arguments

x

a raster or polygon object (sp, raster or terra)

y

a points or polygons spatial object (sp, sf, or terra)

field

character. The field(s) to extract when x is a polygon. If NULL, all fields are extracted and returned. IDs of y are always returned (ID column).

...

passed to terra::extract()

Details

If x and y are both polygons, extract often outputs NA due to misalignments (this can happen even when x == y), even after snap(y, x). To circumvent this problem, intersect is used internally and, if the extract argument fun is passed, it is applied to values of y per polygon ID of x.

Value

a data.table with extracted values and an ID column of y point IDs


PredictiveEcology/LandR documentation built on June 7, 2024, 4:16 p.m.