【发布时间】:2018-12-04 08:13:54
【问题描述】:
我正在尝试从 sf 对象上的字段中获取到每个点的给定距离内的所有点的值的总和,不包括该点的值。
set.seed(123);m=matrix(runif(30,1,40),ncol=3)
loc<-m %>%
as.data.frame %>%
sf::st_as_sf(coords = c(1,2))
a<-st_is_within_distance(loc,dist=10)
> a
Sparse geometry binary predicate list of length 10, where the predicate was `is_within_distance'
1: 1, 6, 10
2: 2, 4
3: 3
4: 2, 4
5: 5, 8
6: 1, 6
7: 7, 9
8: 5, 8
9: 7, 9
10: 1, 10
我们如何获得一个包含这 10 个点和 V3 总和的列表的数据框?
point|sum
1 | sum_of_v3_of(6,10)
2 | sum_of_v3_of(4)
...
使用 postgis 很容易做到这一点,但所有其他代码都在 R 中,并且想学习如何做到这一点。
【问题讨论】: