You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that terra also returns a value for a polygon that does not cover any cell center. In effect the option touches=TRUE is always used for such polygons to avoid returning NA.
I have a use case where I need to extract cell values for the polygons that effectively intersect with cell centers, returning NA when a polygon is not intersecting cell centers.
I think this cannot currently be done with terra::extract()?
I'd be happy to see the small = FALSE argument of raster::extract() – or some equivalent implementation – appear in terra::extract().
Actually I'm in doubt whether the default approach – to mix touches = FALSE for polygons that intersect cell centers and touches = TRUE for polygons that don't intersect cell centers – matches the user's expectation of terra::extract(x, y, touches = FALSE). At least it is not documented in ?terra::extract that a hybrid approach is implemented.
An alternative to adding a small argument could be to distinguish a third value touches = "hybrid" to reflect current behaviour instead of FALSE, but then having a strict implementation of touches = FALSE would be a breaking change.
The text was updated successfully, but these errors were encountered:
With regard to
terra::extract()
I now understand (from https://stackoverflow.com/a/67666183):I have a use case where I need to extract cell values for the polygons that effectively intersect with cell centers, returning
NA
when a polygon is not intersecting cell centers.terra::extract()
?small = FALSE
argument ofraster::extract()
– or some equivalent implementation – appear interra::extract()
.Actually I'm in doubt whether the default approach – to mix
touches = FALSE
for polygons that intersect cell centers andtouches = TRUE
for polygons that don't intersect cell centers – matches the user's expectation ofterra::extract(x, y, touches = FALSE)
. At least it is not documented in?terra::extract
that a hybrid approach is implemented.An alternative to adding a
small
argument could be to distinguish a third valuetouches = "hybrid"
to reflect current behaviour instead ofFALSE
, but then having a strict implementation oftouches = FALSE
would be a breaking change.The text was updated successfully, but these errors were encountered: