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

Returns true if 'leftGeometry' and 'rightGeometry' are within a specified 'distance'.

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_DWithin/ST_DWithin_true.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=383540080a291db4dae25d8fb6aa80ef" alt="ST_DWithin returning true" width="400" height="300" data-path="images/sql-functions/ST_DWithin/ST_DWithin_true.svg" />

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_DWithin/ST_DWithin_false.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=47be95ca6adfb5ca856415e3c8684976" alt="ST_DWithin returning false" width="400" height="300" data-path="images/sql-functions/ST_DWithin/ST_DWithin_false.svg" />

If `useSpheroid` is passed true, ST\_DWithin uses Sedona's ST\_DistanceSpheroid to check the spheroid distance between the centroids of two geometries. The unit of the distance in this case is meter.

If `useSpheroid` is passed false, ST\_DWithin uses Euclidean distance and the unit of the distance is the same as the CRS of the geometries. To obtain the correct result, please consider using ST\_Transform to put data in an appropriate CRS.

If useSpheroid is not given, it defaults to false

## Signatures

```sql theme={"system"}
ST_DWithin (leftGeometry: Geometry, rightGeometry: Geometry, distance: Double, useSpheroid: Optional(Boolean) = false)
```

## Parameters

<ParamField body="leftGeometry" type="Geometry" required>
  The left geometry value.
</ParamField>

<ParamField body="rightGeometry" type="Geometry" required>
  The right geometry value.
</ParamField>

<ParamField body="distance" type="Double" required>
  The distance value.
</ParamField>

<ParamField body="useSpheroid" type="Boolean">
  Whether to use spheroidal distance calculation. Defaults to `false`.
</ParamField>

## Return type

<ResponseField type="Boolean">
  Returns `true` or `false`.
</ResponseField>

## Examples

```sql theme={"system"}
SELECT ST_DWithin(ST_GeomFromWKT('POINT (0 0)'), ST_GeomFromWKT('POINT (1 0)'), 2.5)
```

```
true
```

```text theme={"system"}
Check for distance between New York and Seattle (< 4000 km)
```

```sql theme={"system"}
SELECT ST_DWithin(ST_GeomFromWKT(-122.335167 47.608013), ST_GeomFromWKT(-73.935242 40.730610), 4000000, true)
```

```
true
```
