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

The first variant of the function computes and returns the [Dimensionally Extended 9-Intersection Model (DE-9IM)](https://en.wikipedia.org/wiki/DE-9IM) matrix string representing the spatial relationship between the two input geometry objects.

The second variant of the function evaluates whether the two input geometries satisfy a specific spatial relationship defined by the provided `intersectionMatrix` pattern.

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_Relate/ST_Relate_true.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=bf835a0b2c3a7a7b5c320483223e7ec4" alt="ST_Relate with intersectionMatrix pattern returning true" width="400" height="300" data-path="images/sql-functions/ST_Relate/ST_Relate_true.svg" />

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_Relate/ST_Relate_false.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=5497c050457d214f18eb6107aa5f66fa" alt="ST_Relate with intersectionMatrix pattern returning false" width="400" height="300" data-path="images/sql-functions/ST_Relate/ST_Relate_false.svg" />

<Note>
  It is important to note that this function is not optimized for use in spatial join operations. Certain DE-9IM relationships can hold true for geometries that do not intersect or are disjoint. As a result, it is recommended to utilize other dedicated spatial functions specifically optimized for spatial join processing.
</Note>

## Signatures

```sql theme={"system"}
ST_Relate(geom1: Geometry, geom2: Geometry)
```

```sql theme={"system"}
ST_Relate(geom1: Geometry, geom2: Geometry, intersectionMatrix: String)
```

## Parameters

<ParamField body="geom1" type="Geometry" required>
  The geom1 value.
</ParamField>

<ParamField body="geom2" type="Geometry" required>
  The geom2 value.
</ParamField>

<ParamField body="intersectionMatrix" type="String">
  The intersection matrix value.
</ParamField>

## Return type

<ResponseField type="String">
  A string representation.
</ResponseField>

## Examples

```sql theme={"system"}
SELECT ST_Relate(
        ST_GeomFromWKT('LINESTRING (1 1, 5 5)'),
        ST_GeomFromWKT('POLYGON ((3 3, 3 7, 7 7, 7 3, 3 3))')
)
```

```
1010F0212
```

```sql theme={"system"}
SELECT ST_Relate(
        ST_GeomFromWKT('LINESTRING (1 1, 5 5)'),
        ST_GeomFromWKT('POLYGON ((3 3, 3 7, 7 7, 7 3, 3 3))'),
       "1010F0212"
)
```

```
true
```
