【问题标题】:GEE Python API: Showing image failsGEE Python API:显示图像失败
【发布时间】:2019-12-14 17:15:05
【问题描述】:

我一直在尝试通过 GEE 上的 Python API 进行故障排除,但我无法找出问题所在。我在论坛中搜索了类似的问题,但我找到的解决方案对问题没有帮助。

我现在正在尝试在 Google Colab 上简单地显示一张图片。我的代码如下:

**# Get image collection**
sentinel_collection = ee.ImageCollection('COPERNICUS/S2_SR')
**# Filter by bates**
collection_time = sentinel_collection.filterDate('2017-03-28', '2019-12-08')
**# Create a square over region of interest**
square = ee.Geometry.Rectangle(coords=[
                                       [-77.04931434943427,-12.11990118945657],
                                       [-76.98579963996161,-12.09103199034111]],
                                        proj=None)

collection_bounds = collection_time.filterBounds(square)
**# Filter to remove clouds that have > 5% cover**
clouds = collection_bounds.filter(ee.Filter.lt('CLOUD_COVER', 5))
**# Select appropriate bands**
bands = clouds.select(['B4', 'B3', 'B2'])
**# Create a composite image**
composite = bands.median()
**# Show the image**
Image(url=composite.getThumbUrl({'min':0,'max': 3000}))

我相信在我调用 getThumbnail 方法之前,我的过滤和选择过程都很好:

Image(url=composite.getThumbUrl({'min':0,'max': 3000}))

我得到的错误代码是一般错误 500,根本没有帮助:

    ---------------------------------------------------------------------------
HttpError                                 Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    337   try:
--> 338     return call.execute(num_retries=num_retries)
    339   except apiclient.errors.HttpError as e:

7 frames
HttpError: <HttpError 500 when requesting https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails?fields=name&alt=json returned "An internal error has occurred">

During handling of the above exception, another exception occurred:

EEException                               Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    338     return call.execute(num_retries=num_retries)
    339   except apiclient.errors.HttpError as e:
--> 340     raise _translate_cloud_exception(e)
    341 
    342 

EEException: An internal error has occurred

我一直在四处寻找问题所在,但老实说我不知道​​。在调用 getThumbNail 方法之前,我尝试了不同的过滤选项,但没有成功。

欢迎所有帮助!

【问题讨论】:

    标签: python google-colaboratory google-earth-engine


    【解决方案1】:

    在此处查看文档。

    https://developers.google.com/earth-engine/image_visualization

    在页面底部,它说:

    Note: getThumbURL is intended as a method for producing preview images
    you might include in presentations, websites, and social media posts. 
    Its size limitation is 100,000,000 pixels and the browser can timeout 
    for complicated requests. 
    
    If you want a large image or have a complex process, see the Exporting Data page.
    

    所以,您的图片可能太大了。尝试使其更小或使用Exporting Data(或Python)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多