I'm working on getting google earth engine working with my python setup (Windows 7, Python 2.7.8) using a tutorial I found online (here). I can get EE to initialize, but cannot get it to display an image.
import ee
from IPython.display import Image,display
ee.Initialize()
image = ee.Image('srtm90_v4')
url = image.getThumbURL({'min':0,'max':3000})
Image(url)
The last line returns the following error:
"--------------------------------------------------------------------------- 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"
If I put the url into a web browser and save the image that comes up it saves a PNG. If I append PNG to the url, Image(url+'.png')
Image()
no longer throws an error and instead brings up:
<IPython.core.display.Image object>
display()
should be able to show this, but it also only brings up:
<IPython.core.display.Image object>
If I point Image()
to the saved PNG file it works fine:
Image('./test_thumb.png')
Any ideas on what is causing Image()
to not display the Google Earth Engine thumbnail?
I have tried added %matplotlib lineline
after my initial imports (matplotlib is loaded via my ipython profile).
The cause of the error is using the wrong parameter of the IPython.display.Image
constructor function. The data
parameter is first, and the url
argument is the second.
In Jupyter notebooks you can view the parameter lists for an object by using the help magic function (example: help(Image)
) or by the Shift-Tab
keyboard shortcut.
To resolve the issue, use the keyword arguments form when calling the Image function:
Image(url=url)