Skip to contents

sf::st_intersects() returns a list in which points can match zero, one or several polygons (e.g., a point on a shared boundary). Coercing that list with as.integer() errors for any point that does not match exactly one.

Usage

.first_hit(xy, polys)

Arguments

xy

An sf points object.

polys

An sf polygon object in the same CRS as xy.

Value

An integer vector, one value per point; NA where none match.