A terra-native intersection that first drops the features of each input that cannot possibly intersect the other (via terra::relate()), so the underlying GEOS overlay only processes candidate geometries. Equivalent in result to terra::intersect(), but avoids feeding it large, mostly-disjoint inputs.

intersect_relate(x, y)

Arguments

x, y

SpatVectors (or sources readable by terra::vect()).

Value

A SpatVector of the intersection of the intersecting subsets of x and y; an empty SpatVector when they are disjoint.

Examples

x <- terra::vect("POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0))")
y <- terra::vect("POLYGON ((2 2, 5 2, 5 5, 2 5, 2 2))")
intersect_relate(x, y)
#> class       : SpatVector
#> geometry    : polygons
#> dimensions  : 1, 0  (geometries, attributes)
#> extent      : 2, 3, 2, 3  (xmin, xmax, ymin, ymax)
#> coord. ref. :