Data input:
cell_id Lat_Long Lat Long
15327 28.46852_76.99512 28.46852 76.99512
52695 28.46852_76.99512 28.46852 76.99512
52692 28.46852_76.99512 28.46852 76.99512
29907 28.46852_76.99512 28.46852 76.99512
29905 28.46852_76.99512 28.46852 76.99512
应用测地线并找出距离 b/w cell_id 但它会创建距离列但所有值都是 NAN 。
Code:
Geo = Geodesic.WGS84
n=len(df3)-1
for i in range(0, n):
#df3=df3['Lat'].astype(float)
Lat1=float(df3['Lat'].iloc[i])
Long1=float(df3['Long'].iloc[i])
Lat2=float(df3['Lat'].iloc[i+1])
Long2=float(df3['Long'].iloc[i+1])
df3['dis']=pd.Series(Geo.Inverse( Lat1, Long1, Lat2, Long2))
if(i==n):
df3['dis']=pd.Series()
print df3
输出:
cellid Lat_Long Lat Long dis
15327 28.46852_76.99512 28.46852 76.99512 NaN
52695 28.46852_76.99512 28.46852 76.99512 NaN
52692 28.46852_76.99512 28.46852 76.99512 NaN
29907 28.46852_76.99512 28.46852 76.99512 NaN
29905 28.46852_76.99512 28.46852 76.99512 NaN
39502 28.4572_77.0008 28.4572 77.0008 NaN
what is the problem in this code.