Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm interested in pulling street view data at random within a country.

I can only figure out how to generate a point within a bounding box. Often it pulls data from nearby nations. I'm using a GIS server right now, but I'm interested in removing it from the workflow since it's a pain.

Anybody know of any javascript mapping API that can randomly generate a point within a complex polygon, such as a country boundary?

share|improve this question
Is the Geoserver tag correct here? – underdark Oct 26 '10 at 22:09
up vote 6 down vote accepted

"Random Google Street View. Teleport to a random point on the globe. Filter by country or continent. Share weird and wonderful places with your friends. Now with Antarctica, Brazil"

featured recently on

share|improve this answer
Thanks, I was already using an algorithm, that is mostly identical. Just trying to see if there was a faster way. – Phil Salesses Oct 26 '10 at 1:54

There is a nice javascript implementation of the Ray casting algorithm on CloudDev

Using this it should be quite easy to:

  {create pt as a random point within the envelope}
until (pt is in poly)

An alternative approach if you are working with Google Maps might be the PointInPolygon test from AppDelegate

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.