所以我使用了谷歌地球引擎并处理了他们仓库中的一些示例代码。我正在使用 Python 3.6。看起来谷歌将不再支持 Python 3 中的映射功能ee.mapclient()
。我想知道是否有人找到了合适的解决方法?让我概述一下问题。
我试图加载ee.mapclient
来绘制地图。
import ee
import ee.mapclient
ee.Initialize()
但我得到一个错误:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-13-6d4860410653> in <module>()
1 import ee
----> 2 import ee.mapclient
3 ee.Initialize()
/media/krishnab/lakshmi/anaconda3/envs/pMining/lib/python3.6/site-packages/ee/mapclient.py in <module>()
29
30 import collections
---> 31 import cStringIO
32 import functools
33 import math
ModuleNotFoundError: No module named 'cStringIO'
这个cStringIO
问题很容易解决:
python 3.4.0 email package install: ImportError: No module named 'cStringIO'
所以我去 Google Earth Engine Repo 上发布了一个问题,但发现了一个预先存在的问题:
https://github.com/google/earthengine-api/issues/16
Tk
在这个问题中,开发人员承认了这个问题,但表示由于底层包的限制,他们不会修复它。
这是该问题的引述:
我们一直没有积极维护 mapclient 对象,因为它依赖于 Tk,一个图形用户界面工具包,它在不同的机器上表现不同。您能描述一下您需要 mapclient 的用例吗?我们或许可以提出一种替代方法。
谷歌开发人员提出提交解决方法,但到目前为止尚未发布任何解决方法。
因此,我想知道是否有其他人在 Python3.6 中找到了解决此问题的合适解决方法?
通过一个真正的代码示例,我可以从 Google 示例存储库中提供以下代码:
import datetime
import ee
import ee.mapclient
ee.Initialize()
ee.mapclient.centerMap(-95.738, 18.453, 9)
# Filter the LE7 collection to a single date.
collection = (ee.ImageCollection('LE7_L1T')
.filterDate(datetime.datetime(2002, 11, 8),
datetime.datetime(2002, 11, 9)))
image = collection.mosaic().select('B3', 'B2', 'B1')
# Display the image normally.
ee.mapclient.addToMap(image, {'gain': '1.6, 1.4, 1.1'}, 'Land')
# Add and stretch the water. Once where the elevation is masked,
# and again where the elevation is zero.
elev = ee.Image('srtm90_v4')
mask1 = elev.mask().eq(0).And(image.mask())
mask2 = elev.eq(0).And(image.mask())
ee.mapclient.addToMap(
image.mask(mask1), {'gain': 6.0, 'bias': -200}, 'Water: Masked')
ee.mapclient.addToMap(
image.mask(mask2), {'gain': 6.0, 'bias': -200}, 'Water: Elev 0')