r - Distance Between Points Within Radius at Time Intervals
问题描述
Data looks like this:
ID Lat Long Time
1 3 3 00:01
1 3 4 00:02
1 4 4 00:03
2 4 3 00:01
2 4 4 00:02
2 4 5 00:03
3 5 2 00:01
3 5 3 00:02
3 5 4 00:03
4 9 9 00:01
4 9 8 00:02
4 8 8 00:03
5 7 8 00:01
5 8 8 00:02
5 8 9 00:03
I want to measure how far the IDs are away from each other within a given radius at each given time interval. I am doing this on 1057 ID's across 16213 time intervals so efficiency is important.
It is important to measure distance between points within a radius because if the points are too far away I don't care. I am trying to measure distances between points who are relatively close. For example I don't care how far away ID 1 is from ID 5 but I care about how far ID 4 is from ID 5.
I am using R and the sp package.
解决方案
就我所见,会有多次重复的值。因此,我建议只计算每对坐标的距离一次(即使在 df 中重复多次)作为起点。您可以过滤数据并合并表格。(我会将其添加为评论,但我还没有足够的声誉这样做)。
第一行是:
#Creating a DF with no repeated coordinates
df2 <- df %>% group_by(Lat,Long) %>% summarise()
# Calculating Distances
Dist <- distm(cbind(df2$Long,df2$Lat))
推荐阅读
- windows - PE 文件部分重定位和堆栈 cookie -> 错误
- algorithm - 有没有办法使用单个循环比较数组中的每个元素?
- apache - 为什么我在重新启动 apache2 时会收到 AH00526 语法错误和无效的“command '\xc2\xa0'”?
- c# - MikroTik 和 c# API:使用 ':put' 命令获取无线电名称
- hdfs - Flink RocksDB 性能问题
- php - 使用 codeigniter 的迁移类创建数据库
- python - 使用函数和随机数
- javascript - Scroll Magic Section 擦除高度问题
- python - 如何将处理后的图像保存到python文件夹内的不同文件夹中?
- reactjs - React Native 忽略了状态变化