使Lat&Lang在中心Lat Lang的1000Ft半径内

时间:2018-11-20 22:04:58

标签: python pandas latitude-longitude

我正在使用一个熊猫数据框,其中有4列经纬度。您可以将它们称为接送点。我确定了中心位置的经度和纬度,并确定了圆的半径(1000FT)。我想选择该圆圈内的所有接送点。可能在数据框中创建带有标志的列。

(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

**数据子集

我在stackoverflow中发现了以下问题,但不确定那是否是正确的方法。 Haversine Formula in Python (Bearing and Distance between two GPS points)

更新:到目前为止的解决方案

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

1 个答案:

答案 0 :(得分:1)

准确性(特别是在地球两极附近)有多重要?

最简单的方法是计算出中心点每经度的英尺数。然后,对于每个点,您都可以从中心点计算出经度和纬度的差异(以度为单位),并使用在中心点处正确的转换因子将它们转换为英尺。然后,您将以英尺为单位的距离计算为sqrt(latFeet^2 + longFeet^2)

在任何地方(1个地球周长/ 360度纬度),纬度/英尺转换因子都将是恒定的,但是随着纬度的变化,经度/英尺转换因子也会改变。如果绘制图表并进行三角测量,您会发现在给定纬度下(假设球面)地球周围的距离为2 * Pi * Earth Radius * sin(90 degrees - abs(latitude)),并将其除以360度纬度即可得出每度的距离。 / p>

大约1度的纬度或经度与您正在工作的区域中以英尺为单位的距离相等,这近似值在极点处分解,但是如果您不必在极点附近操作,并且关心地球的扁率,它在1000英尺的距离内应保持相对良好的状态。