Geometric binary operations on pairs of simple feature geometry sets
st_intersection(x, y)st_difference(x, y)
st_sym_difference(x, y)
object of class sf
, sfc
or sfg
object of class sf
, sfc
or sfg
an object of the same class as that of the first argument (x
) with the non-empty geometries resulting from applying the operation to all geometry pairs in x
and y
. In case x
is of class sf
, the matching attributes of the original object(s) are added. The sfc
geometry list-column returned carries an attribute idx
, which is an n x 2
matrix with every row the index of the corresponding entries of x
and y
, respectively.
# a helper function that erases all of y from x:
st_erase = function(x, y) st_difference(x, st_union(st_combine(y)))
Run the code above in your browser using DataLab