Skip to contents

Rotates each geometry counter-clockwise by degrees about its own centroid. The geometry type of the output matches the geometry type of the input.

Usage

ga_rotate_around_centroid(geometry, degrees)

Arguments

geometry

a GeoArrow point, linestring, multilinestring, polygon, or multipolygon array

degrees

angle of rotation; length 1 or the same length as geometry

Value

a GeoArrow array of the same geometry type as the input

References

Rotate

Examples

# a right triangle, whose centroid is not its bounding box center
tri <- geoarrow::as_geoarrow_array(sf::st_sfc(
  sf::st_polygon(list(rbind(c(0, 0), c(4, 0), c(0, 3), c(0, 0))))
))

geoarrow::as_geoarrow_vctr(ga_rotate_around_centroid(tri, 90))
#> <geoarrow_vctr geoarrow.polygon{list}[1]>
#> [1] <POLYGON ((2.3333333 -0.3333333, 2.3333333 3.6666667, -0.6666667 -0.333>