The inverse of ga_explode(). Concatenates every element's parts into one
array, so a list of n elements holding m parts in total becomes an
array of length m.
Arguments
- x
a list array of GeoArrow arrays, as returned by
ga_explode()
Details
Null elements contribute nothing, so the result is shorter than the input whenever an element holds more or fewer than one geometry.
See also
Other cast:
ga_as_point(),
ga_cast_geometry(),
ga_downcast_geometry(),
ga_explode(),
ga_from_wkb()
Examples
fp <- system.file("shape/nc.shp", package = "sf")
nc <- as.data.frame(read_shapefile(fp))
# 100 counties in, one row per polygon part out
length(nc$geometry)
#> [1] 100
ga_flatten(ga_explode(nc$geometry))$length
#> [1] 108