Stratified random sample points in a polygon
A stratified random sample: the polygon cut into square cells of a set size, and a set number of random points placed in each cell's part of the polygon, reproducible from a seed.
Experimental: not yet fully verified. How results are checked
32 points in 16 cells, from seed 42.
- Strata sampled
- Strata skipped
- Seed
- Plane
- Design
Provenance
- Computed by
- geometry.sampling.stratified-points 1.0.0, core 0.1.0
- Model
- Square cells from the lower-left corner of the polygon's bounding box on the UTM plane, side scaled by the zone's point scale at the center; each cell's part of the polygon is the polygon's ear-clipped triangles clipped to the cell; strata taken row by row, south to north and west to east; in each, k points by the random-points method, two draws each, from one xoshiro256** stream (EPA QA/G-5S ch. 6)
- Accuracy
- Every point is inside its cell and the polygon as drawn on the plane; uniform within each stratum by plane area
- Notes
- 1 shown with the answer
- Cites
- US Environmental Protection Agency, Guidance on Choosing a Sampling Design for Environmental Data Collection (EPA QA/G-5S); Osada, R., Funkhouser, T., Chazelle, B., and Dobkin, D., ACM Transactions on Graphics, Shape distributions; Blackman, D., and Vigna, S., ACM Transactions on Mathematical Software, Scrambled linear pseudorandom number generators
Something look off?
How we got thisFormula, worked example, sources, and proof
Model: Square cells from the lower-left corner of the polygon's bounding box on the UTM plane, side scaled by the zone's point scale at the center; each cell's part of the polygon is the polygon's ear-clipped triangles clipped to the cell; strata taken row by row, south to north and west to east; in each, k points by the random-points method, two draws each, from one xoshiro256** stream (EPA QA/G-5S ch. 6)
Show your work
Strata
square cells from the south-west corner, clipped to the polygon100 m cells, 4 × 4= 16 sampled, 0 skippedPoints
k random points in each stratum, 2 draws eachk = 2, seed 42= 32
The same steps an agent gets from the MCP server with explain: true.
Accuracy: Every point is inside its cell and the polygon as drawn on the plane; uniform within each stratum by plane area
When to use this: Use this when the sample must cover the whole site but stay random: each grid cell gets its own random points, so no part of the area is left out. Enter the boundary, the cell size, and how many points per cell.
Limitations: Each cell gets the same number of points however much of the polygon it holds, so a sliver cell at the edge is sampled as heavily as a full one; weigh results by stratum area. Cells with less than 1 m² of the polygon are skipped and listed. At most 50,000 cells and 100,000 points.
Worked example: Two points in each 100 m cell of a field, seed 42. Source: A 340 m × 333 m field in 16 cells.
You enter
- Cell size
- 100 m
- Points per stratum
- 2
- Polygon
- 40, -105 40, -104.996 40.003, -104.996 40.003, -105
- Seed
- 42
You get
- Points placed
- 32
- Strata sampled
- 16
- Strata skipped
- none
- Seed
- 42
- Plane
- UTM zone 13N (WGS 84)
- Design
- Stratified random, 2 per 100 m cell (EPA QA/G-5S ch. 6)
Review: Not yet independently reviewed by a GIS professional.
Last verified: 2026-10-20, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.
Status: version 1.0.0, core 0.1.0. See this tool in the verification report.
Checked against: 21 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.
Sources
- Guidance on Choosing a Sampling Design for Environmental Data Collection (EPA QA/G-5S), US Environmental Protection Agency, EPA/240/R-02/005, December 2002. Chapter 6, stratified sampling (p. 51).
- Shape distributions, Osada, R., Funkhouser, T., Chazelle, B., and Dobkin, D., ACM Transactions on Graphics, Vol. 21, No. 4. Section 4.2, a random point in a triangle: P = (1 − √r₁)A + √r₁(1 − r₂)B + √r₁r₂C. Read free.
- Scrambled linear pseudorandom number generators, Blackman, D., and Vigna, S., ACM Transactions on Mathematical Software, Vol. 47, No. 4. xoshiro256**, seeded by splitmix64 as the authors suggest; doubles from the top 53 bits. Read free.
Experimental means this tool has not yet met the stable bar: at least 20 golden vectors, differential tests, and an independent worked example.