【发布时间】:2021-02-19 04:53:13
【问题描述】:
这是我的可重现示例
########################################
library(sf)
# matrix of lon lat for the definition of the linestring
m<-rbind(
c(12.09136, 45.86471),
c(12.09120, 45.86495),
c(12.09136, 45.86531),
c(12.09137, 45.86540),
c(12.09188, 45.86585),
c(12.09200, 45.86592),
c(12.09264, 45.86622),
c(12.09329, 45.86624),
c(12.09393, 45.86597),
c(12.09410, 45.86585),
c(12.09423, 45.86540),
c(12.09411, 45.86495),
c(12.09393, 45.86471),
c(12.09383, 45.86451),
c(12.09329, 45.86414),
c(12.09264, 45.86413),
c(12.09200, 45.86425),
c(12.09151, 45.86451),
c(12.09136, 45.86471)
)
# define a linestring
ls<-st_linestring(m)
# create a simple feature with appropriate crs
ls<-st_sfc(ls, crs=4326)
# and now again going through the very same
# definition process for a point
# define a point
pt <- st_point(c(12.09286,45.86557))
# crate simple feature with appropriate crs
pt<-st_sfc(pt, crs = 4326)
plot(ls)
plot(pt, add=TRUE)
# this is computing the minimum distance from the point to the line
st_distance(ls, pt)
###############
鉴于上面提到的玩具数据集,我需要找到一个合适的方法来计算:
1 - 线的每个顶点到给定点的距离:这可能很容易通过勾股定理的简单应用计算每对点(线顶点与点)之间的距离来完成,即使我对此很怀疑,因为正在使用 crs(即 epsg 4326,以度为单位),所以我可能需要首先将整个数据集转换为另一个参考系统(使用公制单位)...
2 - 以固定方位角(10°、20°、30°、....、360° 从北方)的点和线之间的距离:这就是我真正迷路的地方.. ..
请给我一些帮助,以便正确进行计算,可能使用我现在正在尝试熟悉的“sf”标准
谢谢
【问题讨论】: