Skip to contents

ga_is_ccw() is TRUE for counter-clockwise geometries and ga_is_cw() is TRUE for clockwise ones. A polygon is tested on its exterior ring.

Usage

ga_is_ccw(geometry)

ga_is_cw(geometry)

Arguments

geometry

a GeoArrow linestring or polygon array

Value

a boolean array of the same length as geometry

Details

Any geometry with no winding order, such as a point or a null geometry, becomes NA rather than FALSE, so the two functions are not simply negations of one another.

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_is_ccw(g))
#> [1] FALSE
as.vector(ga_is_cw(ga_orient(g, "reversed")))
#> [1] TRUE