Merges every polygon in x into a single multipolygon, dropping the
boundaries between any that touch or overlap.
Details
This is the one function in the package that is not length-preserving. It
is an aggregate over the whole array, so it always returns a length 1
array, in the way sum() reduces a vector to a single value.
It is far faster than folding ga_boolean_union() across the array, since it
unions all the rings in one pass. Rows that are not polygonal, and null
rows, are skipped.
See also
Other boolean:
ga_boolean_intersection()
Other aggregate:
ga_collect_agg()
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)))),
sf::st_polygon(list(rbind(c(1, 1), c(3, 1), c(3, 3), c(1, 3), c(1, 1))))
))
# 4 + 4 less the 1 they share
as.vector(ga_unsigned_area(ga_unary_union(x)))
#> [1] 7