> ## 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_Force4D

Converts the input geometry to 4D XYZM representation. Retains original Z and M values if present. Assigning 0.0 defaults if `mValue` and `zValue` aren't specified. The output contains X, Y, Z, and M coordinates. For geometries already in 4D form, the function returns the original geometry unmodified.

<Note>
  Example output is after calling ST\_AsText() on returned geometry, which adds Z for in the WKT for 3D geometries
</Note>

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_Force4D/ST_Force4D.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=cd9a68f17210080da02d14973ad322ac" alt="ST_Force4D" width="500" height="300" data-path="images/sql-functions/ST_Force4D/ST_Force4D.svg" />

## Signatures

```sql theme={"system"}
ST_Force4D(geom: Geometry, zValue: Double, mValue: Double)
```

```sql theme={"system"}
ST_Force4D(geom: Geometry)
```

## Parameters

<ParamField body="geom" type="Geometry">
  The input geometry.
</ParamField>

<ParamField body="zValue" type="Double">
  The Z coordinate value to assign. Defaults to `0.0` if not specified.
</ParamField>

<ParamField body="mValue" type="Double">
  The M (measure) coordinate value to assign. Defaults to `0.0` if not specified.
</ParamField>

## Return type

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

## Examples

```sql theme={"system"}
SELECT ST_AsText(ST_Force4D(ST_GeomFromText('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'), 5, 10))
```

```
POLYGON ZM((0 0 2 10, 0 5 2 10, 5 0 2 10, 0 0 2 10), (1 1 2 10, 3 1 2 10, 1 3 2 10, 1 1 2 10))
```

```sql theme={"system"}
SELECT ST_AsText(ST_Force4D(ST_GeomFromText('LINESTRING(0 1,1 0,2 0)'), 3, 1))
```

```
LINESTRING ZM(0 1 3 1, 1 0 3 1, 2 0 3 1)
```
