首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >terra的含义::最近() to_id列

terra的含义::最近() to_id列
EN

Stack Overflow用户
提问于 2021-09-13 20:06:31
回答 1查看 81关注 0票数 1

我正在尝试使用Rterra::nearest()函数,但我无法理解输出格式,以及如何实际确定哪个点最近!下面是一个简单的例子:

代码语言:javascript
复制
> dest <- terra::vect(data.frame(x = c(0, 0, 5, 5), y = c(0, 5, 0, 5), attr = 1:4), geom = c("x", "y"))
> src <- terra::vect(data.frame(x = c(3, 1, 2), y = c(2, 3, 1)), geom = c("x", "y"))
> near_ret <- terra::nearest(src, dest)
> print(near_ret)
 class       : SpatVector 
 geometry    : points 
 dimensions  : 3, 7  (geometries, attributes)
 extent      : 0, 5, 0, 5  (xmin, xmax, ymin, ymax)
 coord. ref. :  
 names       : from_id from_x from_y to_id  to_x  to_y distance
 type        :   <num>  <num>  <num> <num> <num> <num>    <num>
 values      :       1      3      2     1     5     0    2.828
                     2      1      3     2     0     5    2.236
                     3      2      1     3     0     0    2.236

好的,所以to_xto_ydistance列对我来说是有意义的,而且看起来是正确的。但是to_id对我来说没有任何意义。我本以为该列将索引包含到dest中,但显然没有,因为dest[1, ](0, 0)而不是(5, 0)

我在这里的最终目标是求出最接近每个attr点的dest点的src值。如何找到最近的dest点,以便查找它的attr值?

(这是使用terra版本的1.3-4)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-28 23:57:08

这个错误是在terra版本1.4-4中修复的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69168517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档