【发布时间】:2021-09-06 02:02:11
【问题描述】:
我正在使用 R 中的 sf 包来模拟跨时空在网络中不同节点之间移动的代理样本。
我目前对st_intersects 的一些行为感到困惑:我让代理在坐标单位正方形的每个角之间的节点之间移动,以及通过(.5,.5) 的中心。但是,当我尝试在 st_point(c(.1,.9)) 检测与几何 st_linestring(c(st_point(c(0,0)),st_point(c(0.5,0.5)))) 相交的代理时,我得到一个空谓词返回。
相比之下,如果我检测到仅沿 x 轴或 y 轴移动的代理,我能够正确检测到该点。这是为什么呢?
R v4.0.2 中的最小可重现示例:
library(sf)
l1 <- st_linestring(c(st_point(c(0,1)),st_point(c(0.5,0.5))))
p1 <- st_point(c(.1,.9)) ## on the line between (0,1) and (.5,.5); y=1-x x = f(t)
st_intersects(p1,l1) ## empty
#Sparse geometry binary predicate list of length 1, where the predicate was `intersects'
# 1: (empty)
## in contrast
l2 <- st_linestring(st_point(c(0,0)),st_point(c(1,0)))
p2 <- st_point(c(.1,0)) ## on the line between (0,0) and (1,0) ; y = 0; x = f(t)
st_intersects(p2,l2) ## returns 1 as I would expect
#Sparse geometry binary predicate list of length 1, where the predicate was `intersects'
# 1: 1
【问题讨论】:
标签: r spatial sf spatial-query