Transforms every coordinate by the six coefficients of an affine matrix. The geometry type of the output matches the input.
Details
The coefficients map a coordinate to
x' = a * x + b * y + xoff and y' = d * x + e * y + yoff, the same
ordering PostGIS ST_Affine and Shapely use. The identity transform is
a = 1, b = 0, xoff = 0, d = 0, e = 1, yoff = 0.
This is the general form behind ga_translate(), ga_scale_xy(), ga_rotate_around_centroid(),
and ga_skew(). Reach for those when they fit, since they are clearer at the
call site. Use this one to apply a matrix you already have, or to compose
several steps into a single pass over the coordinates.
All six coefficients are recycled against geometry, so a different
transform can be applied to every row.
Examples
ring <- rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1), c(0, 0))
square <- sf::st_polygon(list(ring))
g <- geoarrow::as_geoarrow_array(sf::st_sfc(square))
# double the width and shift right by 10
res <- ga_affine_transform(g, a = 2, b = 0, xoff = 10, d = 0, e = 1, yoff = 0)
sf::st_as_sfc(geoarrow::as_geoarrow_vctr(res))
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 10 ymin: 0 xmax: 12 ymax: 1
#> CRS: NA
#> POLYGON ((10 0, 12 0, 12 1, 10 1, 10 0))