Skip to main content
Generates a specified quantity of pseudo-random points within the boundaries of the provided polygonal geometry. When seed is either zero or not defined then output will be random. ST_GeneratePoints

Signatures

ST_GeneratePoints(geom: Geometry, numPoints: Integer, seed: Long = 0)
ST_GeneratePoints(geom: Geometry, numPoints: Integer)

Parameters

geom
Geometry
required
The input geometry.
numPoints
Integer
required
The number of points.
seed
Long
default:"0"
The seed value.

Return type

The resulting geometry.

Example

SELECT ST_GeneratePoints(
        ST_GeomFromWKT('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'), 4
)
Due to the pseudo-random nature of point generation, the output of this function will vary between executions and may not match any provided examples.
MULTIPOINT ((0.2393028905520183 0.9721563442837837), (0.3805848547053376 0.7546556656982678), (0.0950295778200995 0.2494334895495989), (0.4133520939987385 0.3447046312451945))