Skip to main content
Sample points from each geometry. Polygonal geometries are sampled uniformly by area and linear geometries uniformly by length. Unsupported and empty geometries produce an empty MultiPoint. Supported geometries also return MultiPoint for every size, including zero and one. Sampling is evaluated by native Spark and Sedona expressions and remains distributed.

Signature

Parameters

int or array - like
required
Number of points to sample from each geometry. An array-like or pandas-on-Spark Series supplies one positional size per row. Local sequences are materialized on the driver; use a distributed Series for large per-row size vectors.
str
default:"'uniform'"
Sampling method. Sedona currently supports only "uniform".
optional
default:"None"
Deprecated alias for rng.
optional
default:"None"
Any seed accepted by numpy.random.default_rng. Fresh generators initialized with the same seed produce reproducible results. Passing an existing Generator or BitGenerator consumes one draw immediately to derive the engine seed.
Accepted for GeoPandas signature compatibility and ignored for uniform sampling.

Returns

GeoSeries
Sampled points with the original index and CRS and the name "sampled_points".
Sedona and GeoPandas use different random number generators, so the sampled coordinates are not expected to be identical for the same seed. An integer seed is reused for every row, matching GeoPandas’s behavior in which congruent geometries receive the same relative sample positions. With rng=None, no reproducibility guarantee is made.A stateful NumPy Generator or BitGenerator is reduced to one engine seed and then varied deterministically by row position, so its state advancement also differs. Validation of values in a distributed size Series is lazy and errors are raised when the result is evaluated.Sampling work and per-row intermediate memory grow with size. The current line sampler materializes an array of sampled points and costs roughly O(size * vertices) per geometry before collecting those points into a MultiPoint. Unsupported nonempty geometry types produce empty MultiPoints without GeoPandas’s per-row warning, avoiding an eager type scan.Sedona follows GeoPandas 1.1.4 and later by always returning a MultiPoint. GeoPandas 1.1.3 and earlier instead return a Point for size=1 and an empty GeometryCollection for size=0, and may collapse duplicate samples.

Examples