Skip to contents

Returns "clockwise" or "counterclockwise" for each geometry. A polygon reports the winding of its exterior ring.

Usage

ga_winding_order(geometry)

Arguments

geometry

a GeoArrow linestring, polygon, or multi part array of either

Value

a string array of the same length as geometry

Details

A multipolygon reports a winding only when every part's exterior ring agrees, and a multilinestring only when every part agrees; a geometry whose parts disagree is NA, since it has no single winding. Any other geometry type, a null geometry, or a ring with fewer than three distinct points is also NA.

References

Winding

See also

Other winding: ga_is_ccw(), ga_orient()

Examples

ring <- matrix(c(0, 0, 0, 1, 1, 1, 1, 0, 0, 0), ncol = 2, byrow = TRUE)
g <- geoarrow::as_geoarrow_array(sf::st_sfc(sf::st_polygon(list(ring))))

as.vector(ga_winding_order(g))
#> [1] "clockwise"