vendredi 28 août 2015

Generate random xy values within two-dimensional circular radius?

I have some points that are located in the same place, with WGS84 latlngs, and I want to 'jitter' them randomly so that they don't overlap.

Right now I'm using this crude method, which jitters them within a square:

r['latitude'] = float(r['latitude']) + random.uniform(-0.0005, 0.0005)
r['longitude'] = float(r['longitude']) + random.uniform(-0.0005, 0.0005)

How could I adapt this to jitter them randomly within a circle?

I guess I want a product x*y = 0.001 where x and y are random values. But I have absolutely no idea how to generate this!

(I realise that really I should use something like this to account for the curvature of the earth's surface, but in practice a simple circle is probably fine :) )




Aucun commentaire:

Enregistrer un commentaire