> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_Affine

Apply an affine transformation to the given geometry.

ST\_Affine has 2 overloaded signatures:

Based on the invoked function, the following transformation is applied:

`x = a * x + b * y + c * z + xOff OR x = a * x + b * y + xOff`

`y = d * x + e * y + f * z + yOff OR y = d * x + e * y + yOff`

`z = g * x + f * y + i * z + zOff OR z = g * x + f * y + zOff`

If the given geometry is empty, the result is also empty.

<img src="https://mintcdn.com/wherobots/AayJA2u8CknIeTgt/images/sql-functions/ST_Affine/ST_Affine.svg?fit=max&auto=format&n=AayJA2u8CknIeTgt&q=85&s=5f60897b630d06c9e47d4f5211184ad3" alt="ST_Affine" width="400" height="180" data-path="images/sql-functions/ST_Affine/ST_Affine.svg" />

## Signatures

```sql theme={"system"}
ST_Affine(geometry, a, b, c, d, e, f, g, h, i, xOff, yOff, zOff)
```

```sql theme={"system"}
ST_Affine(geometry, a, b, d, e, xOff, yOff)
```

## Parameters

<ParamField body="geometry" type="Geometry" required>
  The input geometry to transform.
</ParamField>

<ParamField body="a" type="Double" required>
  The `a` coefficient of the affine transformation matrix.
</ParamField>

<ParamField body="b" type="Double" required>
  The `b` coefficient of the affine transformation matrix.
</ParamField>

<ParamField body="c" type="Double">
  The `c` coefficient of the affine transformation matrix (3D variant only).
</ParamField>

<ParamField body="d" type="Double" required>
  The `d` coefficient of the affine transformation matrix.
</ParamField>

<ParamField body="e" type="Double" required>
  The `e` coefficient of the affine transformation matrix.
</ParamField>

<ParamField body="f" type="Double">
  The `f` coefficient of the affine transformation matrix (3D variant only).
</ParamField>

<ParamField body="g" type="Double">
  The `g` coefficient of the affine transformation matrix (3D variant only).
</ParamField>

<ParamField body="h" type="Double">
  The `h` coefficient of the affine transformation matrix (3D variant only).
</ParamField>

<ParamField body="i" type="Double">
  The `i` coefficient of the affine transformation matrix (3D variant only).
</ParamField>

<ParamField body="xOff" type="Double" required>
  The X translation offset.
</ParamField>

<ParamField body="yOff" type="Double" required>
  The Y translation offset.
</ParamField>

<ParamField body="zOff" type="Double">
  The Z translation offset (3D variant only).
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Examples

```sql theme={"system"}
ST_Affine(geometry, 1, 2, 4, 1, 1, 2, 3, 2, 5, 4, 8, 3)
```

**Input:** `LINESTRING EMPTY`

```
LINESTRING EMPTY
```

**Input:** `POLYGON ((1 0 1, 1 1 1, 2 2 2, 1 0 1))`

```
POLYGON Z((9 11 11, 11 12 13, 18 16 23, 9 11 11))
```

**Input:** `POLYGON ((1 0, 1 1, 2 1, 2 0, 1 0), (1 0.5, 1 0.75, 1.5 0.75, 1.5 0.5, 1 0.5))`

```
POLYGON((5 9, 7 10, 8 11, 6 10, 5 9), (6 9.5, 6.5 9.75, 7 10.25, 6.5 10, 6 9.5))
```

```sql theme={"system"}
ST_Affine(geometry, 1, 2, 1, 2, 1, 2)
```

**Input:** `POLYGON EMPTY`

```
POLYGON EMPTY
```

**Input:** `GEOMETRYCOLLECTION (MULTIPOLYGON (((1 0, 1 1, 2 1, 2 0, 1 0), (1 0.5, 1 0.75, 1.5 0.75, 1.5 0.5, 1 0.5)), ((5 0, 5 5, 7 5, 7 0, 5 0))), POINT (10 10))`

```
GEOMETRYCOLLECTION (MULTIPOLYGON (((2 3, 4 5, 5 6, 3 4, 2 3), (3 4, 3.5 4.5, 4 5, 3.5 4.5, 3 4)), ((6 7, 16 17, 18 19, 8 9, 6 7))), POINT (31 32))
```

**Input:** `POLYGON ((1 0 1, 1 1 1, 2 2 2, 1 0 1))`

```
POLYGON Z((2 3 1, 4 5 1, 7 8 2, 2 3 1))
```
