在neo4j中创建geohash关系 [英] Creating geohash relationships in neo4j
问题描述
我的csv文件包含纬度/经度字段,我想要的是将该纬度/经度转换为 geohash ,然后在不同位置之间建立关系节点基于其geohash值.
该怎么做?
I've csv files that contains latitude/longitude fields, what i want is to convert this latitude/longitude into a geohash and then make a relationship between different location nodes based on their geohash values.
how to do that ?
推荐答案
Neo4j具有空间插件,这会为您的地理数据创建一个R-Tree.因此,您无需直接创建geohash,就可以直接使用此插件.
Neo4j has a spatial plugin, that creates a R-Tree for your geo-data. So instead of creating a geohash, you can directly use this plugin.
此外,Neo4j的最新版本引入了一些新的属性类型,其中一个是point
.看一下文档: https://neo4j.com/docs/developer-manual/3.4/cypher/functions/spatial/
Moreover, the last version of Neo4j has introduced some new types for properties, and one of them is the point
. Take a look at the documentation : https://neo4j.com/docs/developer-manual/3.4/cypher/functions/spatial/
只需创建一个geohash layer
:
CALL spatial.addPointLayerGeohash('my_geohash_layer_name')
然后将您的节点添加到图层:
And then add your node to the layer :
CREATE (n:Node {latitude:60.1,longitude:15.2}) WITH n
CALL spatial.addNode('my_geohash_layer_name',n) YIELD node
RETURN node
您的节点必须具有latitude
& longitude
属性.
Your nodes must have a latitude
& longitude
properties.
这篇关于在neo4j中创建geohash关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!