简体   繁体   English

找到不同个体的一系列坐标到单个点之间的最大距离

[英]find maximum distance between a series of coordinates of different individuals to a single point

I have a series of tracking data in the form of coordinates from individuals leaving and returning to the same place (ie. all of them leaving from the same coordinates) and would like to find the maximum Euclidean distance reached from the starting point for each individual, my data set looks more or less like this我有一系列以坐标形式的跟踪数据,来自个人离开和返回同一个地方(即他们都从同一个坐标离开),并希望找到每个人从起点到达的最大欧几里得距离,我的数据集看起来或多或少是这样的

   LON      LAT      ID year    
-5.473959 51.72998   1  2010    
-5.502444 51.58304   1  2010  
-5.341897 50.97509   1  2010    
-5.401117 50.76360   1  2010 

and the coordinates of the starting point are x=-5.479,y=51.721起点坐标为x=-5.479,y=51.721

ID represents each individual (only shown ID 1 as data set extremely long), where I have more than 100 individuals per year and 8 years of data. ID 代表每个人(仅显示 ID 1 为极长的数据集),其中我每年有超过 100 个人和 8 年的数据。

Any help is appreciated!任何帮助表示赞赏!

Here's an approach with dplyr and distHaversine :这是dplyrdistHaversine的方法:

library(dplyr)
library(geosphere)
data %>% 
  mutate(distance = distHaversine(c(-5.479,51.721), cbind(LON, LAT))) %>%
  group_by(ID) %>%
  summarize(max = max(distance, na.rm = TRUE))
# A tibble: 1 x 2
     ID     max
  <int>   <dbl>
1     1 106715.

The output should be in meters. output 应以米为单位。

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

相关问题 计算R中不同ID长度的个体在两个坐标列组之间的距离 - Calculate the distance between two coordinates columns group by individuals of different ID length in R 计算个体内投影坐标之间的距离(添加距离列?) - Calculating distance between projected coordinates within individuals (adding distance column?) 计算坐标和参考点之间的距离 - Calculating distance between coordinates and reference point 计算不同数据帧中坐标之间的距离 - Calculating distance between coordinates in different dataframes 计算 1 df 中的坐标向量与其他 df 中的单个坐标之间的距离 - Calculate distance between vector of coordinates in 1 df and single coordinates in other df 计算R中一系列xy坐标之间的距离 - Calculating distance between a series of x-y coordinates in R 找到一个点的 xy 坐标,知道它与其他 2 个点的距离 - Find xy coordinates of a point knowing its distance to other 2 points 试图找到纬度和经度坐标对之间的距离 - Trying to find the distance between pairs of latitude and longitude coordinates 计算不同ID的多个坐标之间的距离 - Calculate distance between multiple coordinates of different ID's 如何找到 R 中连续坐标之间的距离? - How can I find the distance between consecutive coordinates in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM