无法在 Jupyter Notebook 中显示 Google Earth Engine 图像

cannot display Google Earth Engine Image in Jupyter Notebook

我正在努力使用我在网上找到的教程让 google 地球引擎与我的 python 设置(Windows 7、Python 2.7.8)一起工作(here)。我可以让 EE 初始化,但无法让它显示图像。

import ee
from IPython.display import Image,display
ee.Initialize()
image = ee.Image('srtm90_v4')
url = image.getThumbURL({'min':0,'max':3000})
Image(url) 

最后一行returns出现如下错误:

"--------------------------------------------------------------------------- ValueError Traceback (most recent call last) in () ----> 1 Image(url)

D:\miniconda\envs\py27\lib\site-packages\IPython\core\display.pyc in init(self, data, url, filename, format, embed, width, height, retina, unconfined, metadata) 750 751 if self.embed and self.format not in self._ACCEPTABLE_EMBEDDINGS: --> 752 raise ValueError("Cannot embed the '%s' image format" % (self.format)) 753 self.width = width 754 self.height = height

ValueError: Cannot embed the 'com/api/thumb?thumbid=a7f37aaf3e0e9a8ec6a0ef27f0a5ff89&token=34a700091c83cadbc034141f7ea765da' image format"

如果我将 url 放入网络浏览器并保存出现的图像,它会保存 PNG。如果我将 PNG 附加到 url,Image(url+'.png') Image() 不再抛出错误,而是显示:

 <IPython.core.display.Image object>

display()应该可以显示这个,但它也只能显示:

 <IPython.core.display.Image object>

如果我将 Image() 指向保存的 PNG 文件,它工作正常:

Image('./test_thumb.png')

SRTM

关于导致 Image() 不显示 Google Earth Engine 缩略图的原因的任何想法?

我尝试在初始导入后添加 %matplotlib lineline(matplotlib 通过我的 ipython 配置文件加载)。

错误的原因是IPython.display.Image构造函数使用了错误的参数。 data参数是第一个,url参数是第二个。

在 Jupyter 笔记本中,您可以使用帮助魔法功能(例如:help(Image))或 Shift-Tab 键盘快捷键来查看对象的参数列表。

要解决此问题,请在调用图像函数时使用 keyword arguments 形式:

Image(url=url)