首页 > 解决方案 > ArcPy AttributeError: 'module' object has no attribute 'FromGeohash'

问题描述

I'm trying to use FromGeohash method in Arcpy but it is failing. Here's my code:

import arcpy
spatial_reference = arcpy.SpatialReference(4326)
print spatial_reference
extent = arcpy.FromGeohash('9q8yyx')

It's giving me the error:

    Traceback (most recent call last):
  File "C:/Python27/ArcGIS10.7/Scripts/Geohash_Converter.py", line 4, in <module>
    extent = arcpy.FromGeohash('9q8yyx')
AttributeError: 'module' object has no attribute 'FromGeohash'

Can anyone tell me what's causing this? Arcpy seems to have been imported correctly.

标签: pythongisarcpygeohashing

解决方案


看起来 FromGeohash 函数仅在 ArcPy 的 ArcPro 版本中可用。如果我尝试导入 ArcMap 版本 (10.6),则会收到错误消息:

from arcpy import FromGeohash

Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name FromGeohash

此外,我能找到的有关 FromGeohash 的唯一文档是 ArcGIS Pro。我在 ArcMap 文档中唯一提到的 Geohash 是针对Data Interoperability 扩展

所以看起来您要么需要使用 ArcGIS Pro python 解释器,要么使用不同的模块来解码 geohash。看起来这个Python 模块可能有效?


推荐阅读