【发布时间】:2020-07-05 23:44:36
【问题描述】:
首先感谢大家对我之前的问题提供的所有帮助。
我试图在下面寻找一个可以找到我的数据集中心坐标的函数:
df <- read.table(sep=",", col.names=c("Start_Latitude","Start_Longitude","End_Latitude", "End_Longitude"),text="43.9567343, -78.8571382, 43.9399364, -78.8497342")
Start_Latitude Start_Longitude End_Latitude End_Longitude
43.9567343 -78.8571382 43.9399364 -78.8497342
我试过这段代码,但它只计算从起始坐标到结束坐标的距离,我想找到中点坐标而不仅仅是距离。我的意思是我需要找到中点的经纬度。
#dd the distance as column in the dataframe
df1$dist <- distm(x = df[, c('Start_Longitude', 'Start_Longitude')],
y = df[, c('End_Longitude', 'End_Latitude')],
fun = distHaversine
)
我有这个数据集:
Start_Latitude Start_Longitude End_Latitude End_Longitude dist
43.9567343 -78.8571382 43.9399364 -78.8497342 13669708
有没有办法找到中点的纬度和经度?另外,我如何计算以公里为单位的距离。
提前谢谢你!
【问题讨论】:
标签: r geolocation coordinates latitude-longitude centroid