Created
July 17, 2019 18:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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