Skip to main content
Question

How to pick a random location on Earth... on land?

  • November 5, 2025
  • 6 replies
  • 134 views

mark2atsafe
Safer
Forum|alt.badge.img+59

Hi FMEers.

I have an interesting task and thought I’d come directly to the experts for advice! I want to pick a random position on Earth, but it has to be on land. How would you go about it?

The obvious route is to simply pick a random coordinate, repeating the process if it doesn't fall within a land boundary. That seems inelegant. 

Alternatively, maybe I could use H3 hexes? Generate all level 15 hexes over land and pick one at random. That seems slow.

I'm open to any suggestions. I want lat/long coordinates to about 7 decimal places, and I need it to run (on Flow) in around 1 or 2 seconds.

Thanks for any suggestions.

Mark

6 replies

philippeb
Enthusiast
Forum|alt.badge.img+22
  • Enthusiast
  • November 5, 2025

1- Add a spatial area reader with the all the countries.

2- Use RandomPointGenerator transformer.

3- Use CoordinateExtractor.

 


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 5, 2025

Sounds like a job for the OpenAIConnector😁


mkludas
Contributor
Forum|alt.badge.img+9
  • Contributor
  • November 6, 2025

What you want to achieve is how I read that the CenterPointReplacer set to “Any inside point” should work:
 


However, it seems like this is not just a point randomly generated on the fly, because I get the exact same point every time I try it with the same input geometry:

Yes, I did remember to set them both to “Any inside point” 😅
My attempt at showing two points at the exact same location



 This would suggest it is not litterally arbitrary, but rather that each specific geometry sets a specific “seed” that produces the exact same result every time … 🤔


redgeographics
Celebrity
Forum|alt.badge.img+62


 This would suggest it is not litterally arbitrary, but rather that each specific geometry sets a specific “seed” that produces the exact same result every time … 🤔

My guess is that it tries centerpoint (and possibly center of gravity) first if it’s set to Any Inside Point, because it’s an easier algorithm and then only switches to a more complex algorithm if it’s necessary.


mkludas
Contributor
Forum|alt.badge.img+9
  • Contributor
  • November 6, 2025


 This would suggest it is not litterally arbitrary, but rather that each specific geometry sets a specific “seed” that produces the exact same result every time … 🤔

My guess is that it tries centerpoint (and possibly center of gravity) first if it’s set to Any Inside Point, because it’s an easier algorithm and then only switches to a more complex algorithm if it’s necessary.

If so, either the phrasing should be updated to reflect this, or the centerpointreplacement procedure should be altered so it is in fact arbitrary.

However, I had a go with this. I first took a polygon and did three separate CenterPointReplacers (CPRs for short ...). In this case, it turns out the cyan Center of Bounding Box (CoBB) and the magenta Any Inside Point (AIP) is identical, i.e. AIP tries to first use CoBB for point placement. The light green Center of Gravity (CoG) is slightly to the southwest of them both.

I then cut of a circle with 1 km diameter around the CoBB point and tried the three CPR algorithms again. The CoBB is identical, the CoG correctly differs only a few meters since the polygon is now a donut with a slightly skew center of gravity, HOWEVER, the AIP is nowhere near either of the other two algorithms, but is instead located way further west:

If I add another CPR with AIP on the same donut polygon this will also be placed at the exact same location. My conclusion is then, that CPR will first try CoBB, and if this fails it will not use CoG but instead generate a point at a specific “random” coordinate, except that the rng seed will be determined by the polygons geometry and thus be exactly the same every time you use the same polygon.

It would be nice to have “random toggle” in there, like you do in the Sampler for instance, as that would solve Mark’s “problem”. :)


hkingsbury
Celebrity
Forum|alt.badge.img+65
  • Celebrity
  • November 7, 2025

I saw your whats up Wednesday before i saw this!

I initially thought you could firstly randomly pick a country, tile it, then select a random tile and generate the center point