2017-07-27 52 views
1

我正在使用我在网上找到的教程(here)让Google地球引擎与我的python安装程序(Windows 7,Python 2.7.8)一起工作。我可以让EE初始化,但无法显示图像。无法在Jupyter Notebook中显示Google Earth Engine图像

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

最后一行返回以下错误:

"--------------------------------------------------------------------------- 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"

如果我把网址在Web浏览器和保存,来了它节省了PNG图像。如果我追加PNG的网址,Image(url+'.png')Image()不再抛出错误,而是带来了:

<IPython.core.display.Image object> 

display()应该能够证明这一点,但它也只是带来了:

<IPython.core.display.Image object> 

如果我点Image()到保存的PNG文件,它工作正常:

Image('./test_thumb.png') 

SRTM

关于导致Image()不显示Google地球引擎缩略图的任何想法?

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

回答

0

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

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

Image(url=url) 

要解决此问题,调用图像功能时所使用的keyword arguments形式