【问题标题】:Download Image from Google Earth Engine `ImageCollection` to drive从 Google Earth Engine `ImageCollection` 下载图像以驱动
【发布时间】:2021-07-21 03:50:55
【问题描述】:

我需要从 ee 集合中下载单个或多个图像。 (最好是多个,但我可以将单个图像代码放在一个循环中)。

我的主要问题 --> 使用缩放 9 下载特定位置(纬度:“”,长:“”)从开始日期到结束日期的每月图像

我正在尝试从SKYSAT/GEN-A/PUBLIC/ORTHO/RGB 下载历史简单卫星数据。这给出了一个类似 -->

的图像

https://developers.google.com/earth-engine/datasets/catalog/SKYSAT_GEN-A_PUBLIC_ORTHO_RGB#description

我正在python 处理这个问题。所以这段代码会给我集合,但我不能下载整个集合,我需要从中选择一个图像。

import ee
# Load a Landsat 8 ImageCollection for a single path-row.
collection = (ee.ImageCollection('SKYSAT/GEN-A/PUBLIC/ORTHO/RGB').filterDate('2016-03-01', '2018-03-01'))
#pp.pprint('Collection: '+str(collection.getInfo())+'\n')

# Get the number of images.
count = collection.size()
print('Count: ', str(count.getInfo()))
image = ee.Image(collection.sort('CLOUD_COVER').first())

这里的image 包含<ee.image.Image at 0x23d6cf5dc70> 属性,但我不知道如何下载它。

另外,我如何使用缩放 19 指定我想要的特定位置(纬度、经度)。

谢谢你

【问题讨论】:

    标签: python google-earth-engine satellite


    【解决方案1】:

    通过构建边界框插入您的分析区域 (geom)。然后,使用下面的代码批量下载图片。

    // Example geometry. You could also insert points etc.
    var geom = ee.Geometry.Polygon(
      [[[-116.8, 44.7],
        [-116.8, 42.6],
        [-110.6, 42.6],
        [-110.6, 44.7]]], None, False)
    
    for (var i = 0; i < count ; i++) {
      var img = ee.Image(collection.toList(1, i).get(0));
      var geom = img.geometry().getInfo();
      Export.image(img, img.get('system:index').getInfo(), {crs: crs, scale: scale, region: geom});
    }
    

    【讨论】:

      【解决方案2】:

      您可以使用geetools 下载图像集中的整个图像。

      您可以使用pip install geetools 安装。

      然后,更改区域、日期和文件夹名称(如果该文件夹不存在,它将在您的驱动器上创建)并执行此代码。

      import geetools
      
      StartDate= ee.Date.fromYMD(2018,1,16)
      EndDate = ee.Date.fromYMD(2021,10,17)
      
      Area = ee.Geometry.Polygon(
              [[[-97.93534101621628, 49.493287372441955],
                [-97.93534101621628, 49.49105034378085],
                [-97.93049158231736, 49.49105034378085],
                [-97.93049158231736, 49.493287372441955]]])
      
      collection =(ee.ImageCollection('SKYSAT/GEN-A/PUBLIC/ORTHO/RGB')
                .filterDate(StartDate,EndDate)
                .filterBounds(Area)
      
      data_type = 'float32'
      name_pattern = '{system_date}'
      date_pattern = 'yMMdd' # dd: day, MMM: month (JAN), y: year
      scale = 10
      folder_name = 'GEE_Images'
      
      tasks = geetools.batch.Export.imagecollection.toDrive(
                  collection=collection,
                  folder=folder_name ,
                  region=Area ,
                  namePattern=name_pattern,
                  scale=scale,
                  dataType=data_type,
                  datePattern=date_pattern,
                  verbose=True,
                  maxPixels=1e10
              )
      

      如果要在本地保存图片,可以将Export.imagecollection.toDrive改为Export.imagecollection.toAsset。您可以阅读this document 了解更多信息。

      【讨论】:

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