Spatially stratified sampling partitions the data into a grid and randomly samples each partition independently.
spatially_stratified_sample
Spatially stratified sampling of a DataFrame containing spatial data.
Each dimension will be rounded to the nearest integer.
def spatially_stratified_sample(dataframe: DataFrame, fraction: float, partition_count: int, geometry: Optional[str], seed: int)
Parameters
DataFrame containing spatial data to be sampled. Must contain a geometry column.
Sampling rate between 0 and 1
Number of partitions to divide the data into. If not a perfect square, the number of partitions
Column containing the geometry data. Default is “geometry”
Seed for sampling the data
Returns
The input DataFrame sampled down to the specified rate.
Usage Examples
from spatially_stratified_sampling import *
# Example usage of spatially_stratified_sample
result = spatially_stratified_sample(dataframe=example_value, fraction=example_value, partition_count=example_value)