I am working with a pandas data frame where I have 4 columns of lats and langs. You can call these as pickup and drop off points. I have identify lat and lang of a central location and figured the radius (1000FT)
of the circle. I want to select all the pickup and drop off points within this circle. Potentially create a column in the data frame with a flag.
(Pdb) x.dtypes
Pickup_longitude float64
Pickup_latitude float64
Dropoff_longitude float64
Dropoff_latitude float64
dtype: object
Pickup_longitude,Pickup_latitude,Dropoff_longitude,Dropoff_latitude
-73.97948455810547,40.68495559692383,-73.97943115234375,40.685020446777344
-74.01079559326173,40.91221618652344,-74.01078033447266,40.91221237182617
-73.92140960693358,40.76670837402344,-73.91441345214845,40.764686584472656
-73.92138671875,40.76667785644531,-73.93142700195312,40.771583557128906
-73.95548248291014,40.71404647827149,-73.94441223144531,40.71472930908203
-73.94529724121094,40.80818557739258,-73.93766784667969,40.821197509765625
-73.89087677001955,40.7464256286621,-73.87692260742188,40.75630569458008
-73.94670104980467,40.79732131958008,-73.9376449584961,40.80451583862305
-73.96315002441406,40.69382858276367,-73.956787109375,40.680530548095696
-73.89682006835938,40.74612808227539,-73.88862609863281,40.752723693847656
-73.82991790771484,40.713768005371094,-73.83494567871094,40.70729064941406
-73.9055404663086,40.77252578735352,-73.8953628540039,40.76896286010742
-73.941650390625,40.81829452514648,-73.950927734375,40.82603073120117
-73.93252563476562,40.85680389404297,-73.93136596679686,40.856117248535156
-73.95282745361328,40.808353424072266,-73.94914245605469,40.80290985107422
-73.904052734375,40.87870788574219,-73.89696502685547,40.90113067626953
-74.02134704589844,40.647010803222656,-74.00405883789062,40.65459442138672
-73.95098876953125,40.68049621582031,-73.9539566040039,40.69042205810547
-73.84967041015625,40.72400665283203,-73.83512878417969,40.70719909667969
-73.9466781616211,40.80628967285156,-73.93624877929686,40.79925155639648
-73.98682403564453,40.70245742797852,-73.97278594970702,40.69290161132813
-73.91205596923827,40.7754020690918,-73.89364624023438,40.76850509643555
-73.9617462158203,40.71377944946289,-73.98593139648438,40.71804809570313
-73.94091033935547,40.69868087768555,-73.94107818603516,40.6828498840332
-73.84423828125,40.72149658203125,-73.8086929321289,40.73440170288085
-73.89108276367188,40.74691009521485,-73.87848663330078,40.7494010925293
-73.84487915039062,40.75502395629883,-73.87222290039062,40.77399063110352
-73.87079620361328,40.73346328735352,-73.87014770507811,40.73357391357422
-73.94847869873048,40.81386184692383,-73.94107055664062,40.81884002685547
** subset of the data
I found following question in stackoverflow but not really sure if thats the correct approach. Haversine Formula in Python (Bearing and Distance between two GPS points)
Update: So far solution
import math
def getPoints(lon, lat):
radius = 1800 # in feet (not sure if this is the right approach)
N = 360
# generate points
circlePoints = []
for k in range(N):
angle = math.pi*2*k/N