繁体   English   中英

在两点之间的直线上找到点的坐标?

[英]Find coordinate of point on a straight line between two points?

如何在 python 中为以下问题编写脚本? 我有一条直线的起点和终点坐标。 我想找到距起点给定距离的点的坐标。

Excel中输入数据的屏幕截图

可能这可能会帮助你。 我已将坐标转换为极坐标,

import pandas as pd
import re

df = pd.DataFrame({"Start_Northing": ["41°10'23"],"Start_Easting":["61°26'24"],"End_Northing":["41°10'42"],
     "End_Easting": ["61°27'00"]})

def dms2dd(s):
    degrees, minutes, seconds = re.split('[°\'"]+', s)
    dd = float(degrees) + float(minutes)/60 + float(seconds)/(60*60)
    return dd

for column in df.columns:
    df['New_'+ str(column)] = df[column].apply(dms2dd)
df['point Easting'] = df[["New_End_Northing", "New_End_Easting"]].apply(tuple, axis=1)
df["point Northing'"] = df[["New_Start_Northing", "New_Start_Easting"]].apply(tuple, axis=1)
df = df.drop(['New_Start_Northing','New_Start_Easting','New_End_Northing','New_End_Easting'],axis=1)
print(df.to_string())

结果是,

  Start_Northing Start_Easting End_Northing End_Easting               point Easting             point Northing'
0       41°10'23      61°26'24     41°10'42    61°27'00  (41.17833333333333, 61.45)  (41.17305555555555, 61.44)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM