Skip to content

Instantly share code, notes, and snippets.

@lukemckinstry
Created July 17, 2019 18:00
Show Gist options
  • Save lukemckinstry/1e33940a5e3c39f851ae73065c8983d0 to your computer and use it in GitHub Desktop.
Save lukemckinstry/1e33940a5e3c39f851ae73065c8983d0 to your computer and use it in GitHub Desktop.
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