Extracts points from raster layers using the original raster layer projection.
genericExtract(x, y, field = NULL, ...)a raster or polygon object (sp, raster or terra)
a points or polygons spatial object (sp, sf, or terra)
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()
a data.table with extracted values and an ID column of y point IDs
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.