Each function pairs x with y row by row and returns the polygonal
result. Each function recycles y against x.
Usage
ga_boolean_intersection(x, y)
ga_boolean_union(x, y)
ga_boolean_difference(x, y)
ga_boolean_xor(x, y)Details
ga_boolean_intersection() keeps the area in both, ga_boolean_union() the area
in either, ga_boolean_difference() the area in x but not y, and
ga_boolean_xor() the area in exactly one of them.
These functions operate on polygons and multipolygons only. They return null for a row whose geometry is any other type, or is null. They always return a multipolygon, since a set operation can split one polygon into several or erase it entirely.
See also
Other boolean:
ga_unary_union()
Examples
x <- geoarrow::as_geoarrow_array(sf::st_sfc(
sf::st_polygon(list(rbind(c(0, 0), c(2, 0), c(2, 2), c(0, 2), c(0, 0))))
))
y <- geoarrow::as_geoarrow_array(sf::st_sfc(
sf::st_polygon(list(rbind(c(1, 1), c(3, 1), c(3, 3), c(1, 3), c(1, 1))))
))
# ga_boolean_intersection() returns the 1x1 overlap of two offset 2x2 squares
as.vector(ga_unsigned_area(ga_boolean_intersection(x, y)))
#> [1] 1