【发布时间】:2019-05-29 19:31:22
【问题描述】:
我正在尝试使用 Python 的 geohash 模块获取 geohash 的边界框(x,y 坐标)。我能够成功读取 geohashes 并获取它们的质心,但是当我尝试使用 geohash.bbox() 方法时,它失败了。代码如下:
#import modules
import Geohash
import csv
dataArray = []
with open('C:\Users\Desktop\data.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
geoHash = row[0] # this is the geohash identifier
trips = row[1]
share_of_trips = row[2]
time_ID = row[3]
perc_trips = row[4]
geoStr = str(geoHash)
latLong = Geohash.decode_exactly(geoStr)
# Get Bounding Box
boundingBox = Geohash.bbox(geoStr)
print boundingBox
我能够成功打印 lat long 对,但无法获取边界框。文档说:
我得到的错误是:
AttributeError: 'module' object has no attribute 'bbox'
当我使用 geohash 而不是 Geohash 时,它会显示 geohash is not defined.
有什么想法吗?先感谢您。我已阅读文档:
geohash.bbox(hashcode) geohash 哈希码的边界框。此方法返回一个字典,键为“s”、“e”、“w”和“n”,分别表示南、东、西和北。
>>> geohash.bbox('ezs42')
{'s': 42.5830078125, 'e': -5.5810546875, 'w': -5.625, 'n': 42.626953125}
【问题讨论】:
-
您使用的是哪个地理哈希库?我的谷歌搜索至少有两个不同的。
-
请查看我修改后的问题 - 我已阅读文档。
-
我认为您混淆了两个不同的地理哈希库。您需要找到具有所需功能的库。
标签: python gis centroid geohashing