Skip to contents

Scales each geometry by x_factor along the x axis and y_factor along the y axis, about the geometry's own centroid. The geometry type of the output matches the geometry type of the input.

Usage

ga_scale_xy(geometry, x_factor, y_factor)

Arguments

geometry

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

x_factor

scaling factor along the x axis; length 1 or the same length as geometry

y_factor

scaling factor along the y axis; length 1 or the same length as geometry

Value

a GeoArrow array of the same geometry type as the input

References

Scale

Examples

sq <- geoarrow::as_geoarrow_array(sf::st_sfc(
  sf::st_polygon(list(rbind(c(0, 0), c(2, 0), c(2, 2), c(0, 2), c(0, 0))))
))

# twice as wide, same height, so the area doubles
geoarrow::as_geoarrow_vctr(ga_scale_xy(sq, 2, 1))
#> <geoarrow_vctr geoarrow.polygon{list}[1]>
#> [1] <POLYGON ((-1 0, 3 0, 3 2, -1 2, -1 0))>
as.vector(ga_unsigned_area(ga_scale_xy(sq, 2, 1)))
#> [1] 8