· 5 min read
How to Generate Random Points in an Area
Manesh Jayawardhana
CIO & Co-founder
Generating a random point within 25 km of a location looks like two random numbers: a random distance from 0 to 25, and a random bearing from 0 to 360.
Plot a thousand of them and they form a dense blob at the centre thinning toward the edge. The sampling is wrong, and the reason is worth understanding because the same error appears in several places.
Why uniform distance clusters at the centre
Area grows with the square of radius. The ring between 24 and 25 km covers far more ground than the disc between 0 and 1 km — roughly 49 times more.
Drawing distance uniformly gives each of those an equal share of the points, so the small central disc receives as many points as the large outer ring. Per unit area, the centre is massively over-sampled.
The correction is a square root:
r = R × √u, where u is uniform between 0 and 1
Taking the square root pushes points outward in exactly the proportion that area increases, producing a distribution that is uniform per unit area rather than per unit distance.
The same problem on a sphere
Sampling latitude uniformly in degrees over-samples the poles, for the same underlying reason.
A degree of longitude spans about 111 km at the equator and only a few kilometres near the poles. Lines of longitude converge, so equal steps in degrees cover progressively less ground as latitude increases — and uniform sampling in degrees therefore packs points together up there.
Correcting for it means sampling the sine of latitude uniformly rather than latitude itself. On a small bounding box the effect is negligible; over a continent or globally it is large and visible.
| Naive approach | Result |
|---|---|
| Uniform distance in a radius | Clustered at centre |
| Uniform latitude in degrees | Clustered at poles |
| Uniform in a small bounding box | Fine — distortion is negligible |
What the points are for changes what you need
Field survey sampling genuinely needs area-uniform points, because the whole purpose is that each unit of ground has an equal chance of selection. Getting this wrong biases the survey.
Test data usually just needs plausible geography, and the distribution matters less than whether the points fall somewhere sensible.
Games and simulations often want deliberately non-uniform distributions — more objectives near a centre, fewer at the edge — in which case uniform distance sampling is the feature rather than the bug.
Knowing which you want is the decision; the correction is trivial once decided.
Points on water and in the wrong places
A radius or bounding box does not know about geography. Generate points around a coastal city and a share of them land in the sea; generate them around a national park and some fall on private land or a military range.
For survey work this means generating more points than needed and filtering, rather than generating exactly the target number. It also means checking the filtered set is still area-uniform — discarding points non-randomly reintroduces bias.
Random is not the same as evenly spread
A property of randomness that surprises people looking at the output.
Uniformly random points cluster. Some areas get several points close together and others get none, and that is what genuine randomness looks like — the eye expects an even spread and reads clustering as a bug.
For sampling, that is correct and desirable, because clustering is exactly what unbiased selection produces.
For other purposes it is not what is wanted. Placing objects in a game, distributing sensors, or laying out anything that should look natural usually wants a blue noise or Poisson disc distribution, which enforces a minimum separation while remaining irregular.
Knowing which you need matters. Asking for random points and rejecting the output because it clusters means you wanted even spacing rather than randomness.
Common mistakes to avoid
- Sampling distance uniformly and getting a centre-heavy cluster.
- Sampling latitude uniformly across a large area.
- Generating exactly the number of points needed when some will be unusable.
- Filtering unusable points in a way that biases the remainder.
- Using a bounding box where the requirement is a radius, which over-samples the corners.
How to do it with Random Coordinate Generator
The Random Coordinate Generator applies the area correction by default.
- Set a centre and radius, or a bounding box.
- Choose uniform by area unless you specifically want a different distribution.
- Generate more points than you need if some will fall on water or inaccessible land.
- Check the points against a map before using them for anything requiring site access.
Other generators are in the tools directory.
Frequently asked questions
Why is there a square root in the radius formula?
Because area grows with the square of radius, so an outer ring covers far more ground than an inner one of the same width. The square root spreads points evenly by area rather than by distance.
Why does uniform latitude over-sample the poles?
Because lines of longitude converge. A degree of longitude covers much less ground at high latitude, so equal steps in degrees pack points closer together there.
What is this used for?
Field survey sampling, generating test data with realistic geography, distributing synthetic load across regions, and placing objectives at random in games.
Final thought
Decide whether you want uniform by area or uniform by distance. They are different distributions, both are sometimes correct, and only one of them is what most people mean.