所以我正在使用Google Earth Engine并在他们的回购中处理一些示例代码.我使用的是
Python 3.6.看起来谷歌将不再通过他们的ee.mapclient()支持Python 3中的映射功能.我想知道是否有人找到了合适的解决方法?让我概述一下这个问题.
我试图加载ee.mapclient来绘制地图.
import ee
import ee.mapclient
ee.Initialize()
但是我收到了一个错误:
ModuleNotFoundError Traceback (most recent call last)
in ()
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 ()
29
30 import collections
---> 31 import cStringIO
32 import functools
33 import math
ModuleNotFoundError: No module named 'cStringIO'
所以我在Google Earth Engine Repo上发布了一个问题,但发现了一个先前存在的问题:
在这个问题中,开发人员承认这个问题,但是由于底层Tk包的限制,他们表示不会修复它.
以下是该问题的引用:
We have not been actively maintaining the mapclient object, because it
depends on Tk, a graphical user interface toolkit, which behaves
differently on different machines.
Could you describe your use case that requires mapclient? We may be
able to suggest an alternative approach.
谷歌开发者提出了提交解决方法,但到目前为止还没有发布任何解决方法.
因此,我想知道是否有其他人在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')