我在Windows 10中使用ipython Jupyter笔记本.我已经在cmd中使用pip install geohash安装了Geohash.当我尝试使用geohash(import geohash)时出现以下错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-840910eb012f> in <module>()
----> 1 import geohash
ImportError: No module named 'geohash'
Run Code Online (Sandbox Code Playgroud)
再次检查是否安装了geohash,然后在我尝试重新安装时发出以下消息:
C:\Users\Himal Acharya>pip install geohash
Requirement already satisfied (use --upgrade to upgrade): geohash in c:\users\himal acharya\anaconda3\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.3 in c:\users\himal acharya\anaconda3\lib\site-packages (from geohash)
Run Code Online (Sandbox Code Playgroud)
我再次卸载geohash.我从github手动安装geohash但出现同样的问题:导入错误
我的要求是:
给定一个经纬度边界框,返回一组 geohashes,使得:
我对算法或概念方法最感兴趣。如果不存在开源实现,我计划在 Android 和 iOS 的 Java/Obj-C 中实现它。
我一直在到处寻找有关如何使用ch.hsr.geohash搜索附近位置的清晰示例。我的意思是,我只需要实现以下情况:
1 - 我有一个长纬度和经度。2 - 将此纬度/经度转换为哈希。(我相信它是通过使用“GeoHash.withBitPrecision(latitude, longitude, 64)”完成的,但我不确定这里的精度是多少。我想 64bits 将具有与 long 3 相同的精度 - 检索纬度列表/ 100 公里范围内的经度(我什至不知道如何使用 geohash 启动它) 4 - 使用纬度/经度结果列表查询对象化对象。
但是我找不到任何关于 lib 的文档,也没有任何明确的例子。请有人建议我或给我任何搜索的起点吗?有没有人已经使用这个库来实现我正在寻找的相同结果?非常感谢!
我正在尝试使用 geohash (手动方式,因为我无法使用 postgres gis 的 geo 方法,因为我正在使用的框架)。
为此,我在 postgres ( geoHash text default ''::text not null) 中有一列来存储该值。
现在解决问题:假设我的列包含c28xzxe29h我尝试使用以下查询查询该记录的值:geoHash <= 'c28x~'但是它不会返回预期值(select 'c28xzxe29h' <= 'c28x~';returns False)。但是,此查询确实可以与 firestore 一起正常工作,并且在例如 javascript 中执行时也可以正常工作(在两种情况下都包含条目/返回 true)。我还用 Rust 对其进行了测试(println!("{}", "c28xzxe29h" <= "c28x~");返回true:https://play.rust-lang.org/)。所以不知道为什么所有编程语言似乎都同意,但 postgres 不同意。
问题是如何让 postgres 返回预期值(我用来geofire-commons生成在某些情况下吐出~字符的查询范围)。
受到XKCD geohashing漫画(http://imgs.xkcd.com/comics/geohashing.png)的启发,我想我已经开始用Python编写生成器了.不过我已经遇到了一个主要部分:转换为MD5然后转换为十进制.
它可能吗?
最近我一直在使用Geotools库(http://docs.geotools.org/latest/javadocs/)来处理一些简单的地理数据。然而,该库是如此强大,以至于令我惊讶的是它似乎没有提供从纬度和经度创建 geohash 的功能。任何人都可以向我指出有关如何使用 Geotools 库创建 geohash 的文档吗?
Geohash字符串是我的稀疏逻辑回归模型中的一个特征.所以我使用java字符串hashCode在geohash字符串上生成int值以获取功能ID.但我发现hashCode方法在类似的geohash字符串上表现不佳.它导致不同的功能具有相同的功能ID,即使功能类似,模型优化也可能不好.例如,那些类似的geohash字符串对具有相同的hashCode.
<"wws8vw", "wws8x9">
"wws8vw".hashCode() = -774715770
"wws8x9".hashCode() = -774715770
<"wmxy0", "wmxwn">
"wmxy0".hashCode() = 113265337
"wmxwn".hashCode() = 113265337
Run Code Online (Sandbox Code Playgroud)
我猜它在geohash生成器方法和java hashCode方法之间有一些关系.那么,任何人都可以向我解释真正的原因以及如何减少geohash字符串上的冲突?
import pygeohash as pgh
pgh.encode(45,55)
'tpzpgxczbzur'
Run Code Online (Sandbox Code Playgroud)
上述步骤效果很好。下面我试图创建一个数据框:
l = [(45,25),(75,22),(85,20),(89,26)]
rdd = sc.parallelize(l)
geoCords = rdd.map(lambda x: Row(lat=x[0], long=int(x[1])))
geoCordsSchema = sqlContext.createDataFrame(geoCords)
geoCordsSchema.show()
+---+----+
|lat|long|
+---+----+
| 45| 25|
| 75| 22|
| 85| 20|
| 89| 26|
+---+----+
Run Code Online (Sandbox Code Playgroud)
这成功创建了一个火花数据框。现在我正在使用Pygeohash编码,并抛出如下错误:
pgh.encode(geoCordsSchema.lat, geoCordsSchema.long, precision = 7)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pygeohash/geohash.py", line 96, in encode
if longitude > mid:
File "/usr/local/spark/python/pyspark/sql/column.py", line 427, in __nonzero__
raise ValueError("Cannot convert column into bool: please use …Run Code Online (Sandbox Code Playgroud) 目前,我正在使用 GeoFirebase 库的部分内容以及 Firestore 来进行地理查询。当我设置帖子的 geohash 时,我是这样做的if let geoHash = GFGeoHash(location: location.coordinate).geoHashValue {
但是,为了使 geohash 查询不那么具体,我计划在查询时截断部分 geohash;目前,查询看起来与此类似
var geoQuerySpecific = GFGeoHashQuery()
let geoQueryHash = GFGeoHashQuery.queries(forLocation: (lastLocation?.coordinate)!, radius: (30)) as! Set<GFGeoHashQuery>
for query in geoQueryHash {
geoQuerySpecific = query
print("the key is this um \(geoQuerySpecific)")
}
print("the starting value is \(geoQuerySpecific.startValue) and the end value is \(geoQuerySpecific.endValue)")
let nearQuery = Firestore.firestore().collection("stuff").order(by: "g").whereField("g", isGreaterThanOrEqualTo: geoQuerySpecific.startValue).whereField("g", isLessThanOrEqualTo: geoQuerySpecific.endValue)
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这将无法正常工作,因为 geoQueryHash 中有多个项目。当我在 firebase 中设置 geohash 时,我考虑过截断 geohash 的最后四位数字/字母,但是,这还不够具体。为了获得最接近的帖子,最好像我现在一样在数据库中设置 geoHashes,然后,在检索内容时,将起始值设置为查询的最具体的 geohash,然后将最终值设置为截断版本geohash,从获取最近的帖子开始并以最广泛的帖子结束?
我可以将 Firestore …
geolocation geohashing geofire google-cloud-firestore geofirestore
geohashing ×9
geolocation ×3
java ×2
python ×2
geofire ×1
geofirestore ×1
geospatial ×1
geotools ×1
gis ×1
hashcode ×1
ipython ×1
map ×1
md5 ×1
postgresql ×1
pyspark ×1