I have a world map. I need random point geometry. So, how can I randomly generate point coordinates? Any programming language. Also, I am using SRID 4326.

Any programming language.

  • Do you just need a single point? – Nathan W Apr 28 '13 at 8:43
  • Yes, but it should be absolutely random coordinate. – Dmitri Apr 28 '13 at 8:45
  • But algorthm for n points will be also a good choice – Dmitri Apr 28 '13 at 8:46

With some Python:

from random import uniform
x, y = uniform(-180,180), uniform(-90, 90)

or for a loop:

def newpoint():
   return uniform(-180,180), uniform(-90, 90)

points = (newpoint() for x in xrange(10))
for point in points:
   print point
|improve this answer|||||
  • Nice, simple solution. – Fezter Apr 29 '13 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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