Skip to contents

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.

Usage

ga_flatten(x)

Arguments

x

a list array of GeoArrow arrays, as returned by ga_explode()

Value

a GeoArrow array holding every part, flattened

Details

Null elements contribute nothing, so the result is shorter than the input whenever an element holds more or fewer than one geometry.

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