我试图在kepler.gl中映射附加的kepler.gl数据集。我使用以下scala函数以8的分辨率索引生成这些函数。
val geoToH3 = udf{ (latitude: Double, longitude: Double, resolution: Int) =>
H3.instance.geoToH3(latitude, longitude, resolution) https://drive.google.com/file/d/1Wffsi1GoRGox8r3s_HYWRqFTtKKP_s8B/view?usp=sharing
当我在终端中对相同的经度值使用h3时,它给出了一个不同的hex_index:
示例:
./bin/geoToH3 --resolution 8 --latitude 46.81355 --longitude -71.22968返回882bac516bfffff的
这两个hex_indexes都是正确的吗?
而且,当我试图在kepler.gl中映射时,我什么也看不见。
发布于 2020-01-22 19:38:45
H3索引是64位整数,通常编码为十六进制字符串.看起来,Scala代码是以基-10格式输出整数,这在内存中可能很好(对于支持64位整数的语言而言),但通常不用作数据交换格式。特别是Javascript不能支持64位整数,并且需要十六进制字符串。
因此,CLI输出882bac516bfffff是正确的。您可能需要更新Scala代码,以便用十六进制打印输出。
至于开普勒,你用的是H3层吗?您需要在包含H3索引的数据中指定H3层和列。
发布于 2020-01-23 02:24:04
我在下面分享我的最后代码,以防有人发现它有用。这是在databricks笔记本中执行的。
%scala
import org.locationtech.jts.geom._
import org.locationtech.geomesa.spark.jts._
import org.apache.spark.sql.types._
import org.apache.spark.sql.functions._
import spark.implicits._
spark.withJTS
object H3 extends Serializable { val instance = H3Core.newInstance()
}
val geoToH3 = udf{ (latitude: Double, longitude: Double, resolution:
Int) => H3.instance.geoToH3(latitude, longitude, resolution) }
val res = 8 //the resolution of the H3 index, 0.461354684 km edge length
val dfH3 = df_scala.withColumn(
"hex_id",
hex(geoToH3(col("latitude"), col("longitude"), lit(res)))
)https://stackoverflow.com/questions/59866891
复制相似问题