Skip to contents

Returns "clockwise" or "counterclockwise" for each geometry. For a polygon, ga_winding_order() reports the winding of the 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

ga_winding_order() reports a winding for a multipolygon only when every part's exterior ring agrees, and for a multilinestring only when every part agrees; it returns NA for a geometry whose parts disagree, since that geometry has no single winding. It also returns NA for any other geometry type, a null geometry, or a ring with fewer than three distinct points.

References

Winding

See also

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"