用多个起始坐标计算距离
我计算了称为 dands_m
的行进距离,每个日期使用功能 points_in_circle
for两个ID为 hex_tag_id
。我在功能中放置的坐标基于ID“ 3D6.15341BBB4F”的 datum
“ 2022-04-21”。但是,其余ID在“ 2022-04-21”之日具有不同的坐标集。这意味着对“ 3D6.15341BC60F”进行了错误执行的计算。
如何自动化此功能以计算与相应的坐标的行进距离?特别是如果我想将来添加更多ID。关键点:坐标基于 datum
“ 2022-04-21”的每个唯一`hex_tag_id。
library(spatialrisk)
Distance_ind <- points_in_circle(Distance_ind, lat_center = 51.93349, lon_center = 4.70912, lon = Longitude, lat = Latitude, radius = 1e6)
df = decand_ind
structure(list(Datum_Tijd = structure(c(1650535073, 1653637570,
1653285342, 1654242563, 1654578739, 1654837567, 1653899310, 1655108033,
1653900853, 1653286920, 1653639081, 1654838913, 1653032146, 1655110494,
1654580434, 1654244601, 1650533634), tzone = "", class = c("POSIXct",
"POSIXt")), Datum = structure(c(19103, 19139, 19135, 19146, 19150,
19153, 19142, 19156, 19142, 19135, 19139, 19153, 19132, 19156,
19150, 19146, 19103), class = "Date"), Tijd = c("11:57:53", "09:46:10",
"07:55:42", "09:49:23", "07:12:19", "07:06:07", "10:28:30", "10:13:53",
"10:54:13", "08:22:00", "10:11:21", "07:28:33", "09:35:46", "10:54:54",
"07:40:34", "10:23:21", "11:33:54"), Reader_ID = c("A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0"), HEX_Tag_ID = c("3D6.15341BBB4F", "3D6.15341BBB4F",
"3D6.15341BBB4F", "3D6.15341BBB4F", "3D6.15341BBB4F", "3D6.15341BBB4F",
"3D6.15341BBB4F", "3D6.15341BBB4F", "3D6.15341BC60F", "3D6.15341BC60F",
"3D6.15341BC60F", "3D6.15341BC60F", "3D6.15341BC60F", "3D6.15341BC60F",
"3D6.15341BC60F", "3D6.15341BC60F", "3D6.15341BC60F"), Longitude = c(4.70912,
4.70917, 4.70918, 4.70918, 4.70914, 4.70914, 4.70927, 4.70921,
4.70904, 4.70903, 4.70906, 4.709, 4.70901, 4.70903, 4.70902,
4.70902, 4.70925), Latitude = c(51.933491, 51.934189, 51.9342,
51.934269, 51.93428, 51.934292, 51.934341, 51.934441, 51.932499,
51.932491, 51.932468, 51.932369, 51.93235, 51.932339, 51.932331,
51.932308, 51.934891), x = c(108366.11, 108370.273, 108370.972,
108371.043, 108368.304, 108368.317, 108377.308, 108373.285, 108359.578,
108358.882, 108360.921, 108356.692, 108357.36, 108358.724, 108358.028,
108358.004, 108376.503), y = c(438553.585, 438631.208, 438632.425,
438640.102, 438641.351, 438642.686, 438648.054, 438659.218, 438443.273,
438442.39, 438439.812, 438428.836, 438426.716, 438425.479, 438424.595,
438422.037, 438709.256), `Lengte_(cm)` = c(9.7, 9.7, 9.7, 9.7,
9.7, 9.7, 9.7, 9.7, 11.2, 11.2, 11.2, 11.2, 11.2, 11.2, 11.2,
11.2, 11.2), Geslacht = c("vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw"), Sloot = c("22",
"22", "22", "22", "22", "22", "22", "22", "22", "22", "22", "22",
"22", "22", "22", "22", "22"), Lengte_8e_lichting = c(NA, NA,
NA, NA, NA, NA, NA, 10.3, NA, NA, NA, NA, NA, 12.5, NA, NA, NA
), Lengteklasse = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), .Label = c("6", "7", "8",
"9", "10", "11", "12", "13"), class = "factor"), distance_m = c(0.111319490512219,
77.8879654012696, 79.1440538153195, 86.8156131287763, 87.953110772786,
89.2887843834125, 95.2906913528804, 106.044905287657, 110.454187269549,
111.379609951795, 113.843032832766, 125.060674080157, 127.12861901825,
128.277561285803, 129.201736097579, 131.75853920649, 156.213638336975
)), row.names = c(NA, -17L), class = c("tbl_df", "tbl", "data.frame"
))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是
data.table
+geosphere
方法...它使用distgeo
来计算与第一个坐标对的距离(即c(经度[1],纬度[1])
)的每个hex_tag_id
带有行的当前经度纬度NCOL = 2))。Here is a
data.table
+geosphere
approach... It uses thedistGeo
to calculate distance from the first coordinate-pair (i.e.c(Longitude[1], Latitude[1])
) of eachHEX_Tag_ID
with the current Longitude-Latitude of the row (matrix(c(Longitude, Latitude), ncol = 2)
).