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

# GeoSeries.sample_points

> Sample points from each geometry.

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

```python theme={"system"}
sample_points(size, method='uniform', seed=None, rng=None, **kwargs) -> GeoSeries
```

## Parameters

<ParamField path="size" type="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.
</ParamField>

<ParamField path="method" type="str" default="'uniform'">
  Sampling method. Sedona currently supports only `"uniform"`.
</ParamField>

<ParamField path="seed" type="optional" default="None">
  Deprecated alias for `rng`.
</ParamField>

<ParamField path="rng" type="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.
</ParamField>

<ParamField path="kwargs">
  Accepted for GeoPandas signature compatibility and ignored for
  uniform sampling.
</ParamField>

## Returns

<ResponseField name="return" type="GeoSeries">
  Sampled points with the original index and CRS and the name
  `"sampled_points"`.
</ResponseField>

<Note>
  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.
</Note>

## Examples

```python theme={"system"}
>>> from sedona.spark.geopandas import GeoSeries
>>> from shapely.geometry import LineString, Polygon
>>> s = GeoSeries(
...     [
...         Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]),
...         LineString([(0, 0), (2, 0)]),
...     ]
... )
>>> s.sample_points(size=3, rng=7).count_geometries()
0    3
1    3
dtype: int64
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.