簡體   English   中英

導出 Google Earth Engine 圖像集合中的所有圖像(Google Earth Engine API)

[英]Exporting all images in a Google Earth Engine image collection (Google Earth Engine API)

我需要為我的論文下載一堆 Landsat 圖像。 我的問題似乎很簡單,但我對 JavaScript 一無所知,而且文檔也沒有提供足夠的幫助。 我已將集合過濾到我所在的地區和時間段,並且我想將所有圖像單獨導出到雲端硬盤。 收藏示例:

var surfaceReflectanceL5 = ee.ImageCollection('LANDSAT/LT5_SR');
var dateSR5=surfaceReflectanceL5.filterDate('1984-01-01', '1985-01-01');
var prSR5=dateSR5.filter(ee.Filter.eq('wrs_path', 182))
                     .filter(ee.Filter.eq('wrs_row', 35)); 

導出單個圖像的代碼是:

Export.image.toDrive({
  image: image1 //example, var image1='Landsat/....'
  description: 'L51984_1',
  scale: 30,
});

如何遍歷集合以導出所有圖像? 使用 map() 函數似乎是答案。

prSR5.map(Export.image.toDrive({
  image: image,
  description: 'L51984',
  scale: 30,
}));

問題是如何將圖像參數設置為正確的圖像(即首先是第一個圖像,然后是第二個圖像,例如“ thisImage() ”)和匹配圖像的描述(即'L51984_1''L51984_2' .. .)

提前謝謝了!!!

我創建了一個函數來執行類似的操作。 它在我創建的一堆 Gee 工具中可用: https : //github.com/fitoprincipe/geetools-code-editor

這是代碼:

/* 
 * Author: Rodrigo E. Principe
 * License: Apache 2.0

PURPOSE:
This function Exports all images from one Collection
PARAMETERS:
col = collection that contains the images (ImageCollection) (not optional)
folder = the folder where images will go (str) (not optional)
scale = the pixel's scale (int) (optional) (defaults to 1000) (for Landsat use 30)
type = data type of the exported image (str) (option: "float", "byte", "int", "double") (optional) (defaults to "float")
nimg = number of images of the collection (can be greater than the actual number) (int) (optional) (defaults to 500)
maxPixels = max number of pixels to include in the image (int) (optional) (defults to 1e10)
region = the region where images are on (Geometry.LinearRing or Geometry.Polygon) (optional) (defaults to the image footprint)
Be careful with the region parameter. If the collection has images 
in different regions I suggest not to set that parameter
EXAMPLE:
ExportCol(myLandsatCol, "Landsat_imgs", 30)
*/

var ExportCol = function(col, folder, scale, type,
                         nimg, maxPixels, region) {
    type = type || "float";
    nimg = nimg || 500;
    scale = scale || 1000;
    maxPixels = maxPixels || 1e10;

    var colList = col.toList(nimg);
    var n = colList.size().getInfo();

    for (var i = 0; i < n; i++) {
      var img = ee.Image(colList.get(i));
      var id = img.id().getInfo();
      region = region || img.geometry().bounds().getInfo()["coordinates"];

      var imgtype = {"float":img.toFloat(), 
                     "byte":img.toByte(), 
                     "int":img.toInt(),
                     "double":img.toDouble()
                    }

      Export.image.toDrive({
        image:imgtype[type],
        description: id,
        folder: folder,
        fileNamePrefix: id,
        region: region,
        scale: scale,
        maxPixels: maxPixels})
    }
  }

我沒有嘗試過很多,但在我做的幾個測試中工作,例如:

var batch = require('users/fitoprincipe/geetools:batch')

var col = ee.ImageCollection("LEDAPS/LE7_L1T_SR").filterDate("2002-01-01","2002-01-03");
batch.Download.ImageCollection.toDrive(col, "Folder", {scale:30});

如果您有任何問題,可以在這里發表評論,也可以在 github 上發布。

性能嘗試但它不起作用...沒有錯誤,沒有任務。 提前致謝!

// Digitalize your AOI: geometry  

// Load the Sentinel-1 ImageCollection.
// Band selection: VV, VH & Incidende Angle (default), Mode: IW, Spatial Resolution : 10m
var imgVVVH = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
        .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
        .filter(ee.Filter.eq('resolution_meters', 10))
        .filter(ee.Filter.eq('instrumentMode', 'IW'));


// 3. Definición de las órbitas y rango de fechas
//
// Tipo de orbita
var asc = imgVVVH.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING'));
var desc = imgVVVH.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));
//Rango de fechas
var date = ee.Filter.date('2015-03-01', '2015-04-01');

// Filter by date and geometry, create multiband image and transform to Float.
var ascArea = asc.filter(date).filterBounds(geometry).toBands().toFloat();
var descArea = desc.filter(date).filterBounds(geometry).toBands().toFloat();

/*
//6. Recortar y guardar
//
// Clip & Save
// Modificar para las diferentes trayectorias; Ascendente default
function clipySave (ascArea){// (ascArea), (descArea)
  var imagenclip = ascArea.clip(geometry)
  //var imagenclip = descArea .clip(geometry)
  Export.image.toDrive(ascArea)
  //Export.image.toDrive(descArea)
  return imagenclip
}
*/

//Performing your code.............No errors, No tasks

var col= ascArea.clip(geometry);
var folder = 'Download_S1';


var ExportCol = function(col, folder, scale, type,
                         nimg, region) {
    type = 'float';
    nimg =  nimg || 500;
    scale = scale || 10;
    //maxPixels = maxPixels || 1e10;

    var colList = col.toList(nimg);
    var n = colList.size().getInfo();

    for (var i = 0; i < n; i++) {
      var img = ee.Image(colList.get(i));
      var id = img.id().getInfo();
      region = region || img.geometry().bounds().getInfo()["coordinates"];

      var imgtype = {"float":img.toFloat(), 
                     "byte":img.toByte(), 
                     "int":img.toInt(),
                     "double":img.toDouble()
                    }

      Export.image.toDrive({
        image:imgtype[type],
        description: id,
        folder: folder,
        fileNamePrefix: id,
        region: region,
        scale: scale})
        //maxPixels: maxPixels})
    }
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM