Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jitter overlapping points, plot in an evenly spaced circle around the original center
#jitter overlapping points, plot in an evenly spaced circle around the original center
import math
def geo_jitter(points_to_jitter):
for i in range(len(points_to_jitter)):
r = .01
angle = 0 + ((360/len(points_to_jitter)) * i)
cur_lat = float(points_to_jitter[i]['lat'])
cur_lon = float(points_to_jitter[i]['lon'])
new_lat = cur_lat + (r * math.cos(angle * (math.pi/180)))
new_lon = cur_lon + (r * math.sin(angle * (math.pi/180)))
points_to_jitter[i]['lat'] = str(new_lat)
points_to_jitter[i]['lon'] = str(new_lon)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.