python - How to make groups using latitude and longitude coordinates? -


i have time series dataset pickup , drop off latitude , longitude coordinates given. since coordinates of city hardly vary, how categorize them in python?

i want make groups classification algorithm can applied.

i pasting single row of pick , drop off longitude , latitude coordinates of new york city.

-73.973052978515625 40.793209075927734 -73.972923278808594 40.782520294189453

i have fixed range of latitude 40.6 40.9 , longitude range -73.9 -74.25

now, want make them groups classification algorithm can applied.

for example can insert coordinates in list of tuples called coordinates. please note have appended couple of coordinates out of range. here code:

coordinates = [     (-73.973052978515625,40.793209075927734),     (-73.972923278808594,40.782520294189453),      (-75.9,40.7)     ]  filtered = list()  # filtering coordinates c in coordinates:     if  -74.25 <= c[0] <= -73.9 , 40.6 <= c[1] <= 40.9:         filtered.append(c)  print filtered # here have filtered coordinates 

output:

[(-73.97305297851562, 40.793209075927734), (-73.9729232788086, 40.78252029418945)] 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -