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

# Spatially Stratified Sampling Scala Object

## `spatiallyStratifiedSample`

Spatially stratified sampling of a DataFrame containing spatial data.

DataFrame containing spatial data to be sampled. Must contain a geometryColumn column.
SpatiallyStratifiedSampling rate between 0 and 1
Number of partitions to divide the data into. If not a perfect square, the number of
partitions in each dimension will be rounded to the nearest integer.
Column containing the geometry data. Default is "geometry"
Seed for sampling the data

```scala theme={"system"}
def spatiallyStratifiedSample(
      dataframe: Dataset[Row],
      fraction: Double,
      partitionCount: Int,
      geometry: String = null,
      seed: Long = 42): Dataset[Row] =
```

### Parameters

<ParamField path="dataframe" type="Dataset[Row]">
  DataFrame containing spatial data to be sampled. Must contain a geometryColumn column.
</ParamField>

<ParamField path="fraction" type="Double">
  SpatiallyStratifiedSampling rate between 0 and 1
</ParamField>

<ParamField path="partitionCount" type="Int">
  Number of partitions to divide the data into. If not a perfect square, the number of partitions in each dimension will be rounded to the nearest integer.
</ParamField>

<ParamField path="geometry" type="String">
  Column containing the geometry data. Default is "geometry"
</ParamField>

<ParamField path="seed" type="Long">
  Seed for sampling the data
</ParamField>

### Returns

The input DataFrame sampled down to the specified rate

### Usage Examples

```scala theme={"system"}
import org.apache.sedona.stats.clustering.SpatiallyStratifiedSampling

// Example usage
val result = SpatiallyStratifiedSampling.spatiallyStratifiedSample(dataframe, epsilon, minPts)
```
