gpt4 book ai didi

javascript - 导出 Google Earth Engine 图像集合中的所有图像 (Google Earth Engine API)

转载 作者:数据小太阳 更新时间:2023-10-29 05:56:55 28 4
gpt4 key购买 nike

我需要为我的论文下载一堆 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 上发布。

关于javascript - 导出 Google Earth Engine 图像集合中的所有图像 (Google Earth Engine API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43868762/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com