如何在H3库中找到给定半径(公里)下一个基本单元的邻居索引/单元格?

huangapple go评论75阅读模式
英文:

How to find the neighbour indexes/cells of a base cell at a given radius(Km) in the H3 library

问题

我不知道如何找到给定半径(公里)下基本单元的相邻单元。我该如何实现这个功能?如果可能的话,我希望使用h3-go库,因为我熟悉Go语言。

英文:

I have no idea how to find the neighbouring cells of the base cell at a given radius(Km). How can I achieve this? If possible for the h3-go library as I am familiar with Go.

答案1

得分: 2

这里的答案取决于你是想要一个真实的半径检查,还是使用kRing进行快速近似。你可以在这个 Observable 笔记本中找到关于这个问题的讨论和示例代码(使用 JavaScript)。基本算法如下:

  1. 确定与你想要的真实距离半径相对应的网格单元半径
  2. 调用 kRing(origin, gridDistance) 来获取在该网格距离内的单元格集合。

这种方法比真实的半径检查要快得多,但略微不太准确。

英文:

The answer here depends on whether you want a true radius check, or a fast approximation using kRing. You can find a discussion and example code (in JavaScript) in this Observable notebook. The basic algorithm is

  1. Determine the grid cell radius corresponding to the true distance radius you want
  2. Call kRing(origin, gridDistance) to get the set of cells within that gridDistance.

This is much faster than a true radius check, but slightly less accurate.

huangapple
  • 本文由 发表于 2021年3月6日 21:17:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/66506046.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定