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

Computes spatial connected components across the entire dataframe using the `ST_DWithin` predicate. Two geometries are in the same component if they are within the specified distance of each other. Returns a component ID for each row.

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

* `geometry` is the geometry column to analyze.
* `distance` is the maximum distance threshold for considering two geometries as connected.
* `useSpheroid` is whether to use a spheroidal distance calculation (default: false).
* `partitionBy` is an optional column to partition the data before computing connected components. When provided, the spatial predicate is only evaluated between rows that share the same partition value. This can significantly improve performance on large datasets.

## Signatures

```sql theme={"system"}
ST_DWithinCC(geometry: Geometry, distance: Double)
```

```sql theme={"system"}
ST_DWithinCC(geometry: Geometry, distance: Double, useSpheroid: Boolean)
```

```sql theme={"system"}
ST_DWithinCC(geometry: Geometry, distance: Double, useSpheroid: Boolean, partitionBy: Column)
```

## Parameters

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

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

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

<ParamField body="partitionBy" type="Column">
  The partition by value.
</ParamField>

## Return type

<ResponseField type="Long">
  The connected component ID for each row.
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_DWithinCC(geom, 1.0, False) FROM my_table
```

```
85899345920
```
