公告 :所有在
2025 年 4 月 15 日 之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件 ,才能继续使用 Earth Engine。
发送反馈
Export.image.toDrive
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建批量任务以将图片导出为栅格到 Google 云端硬盘。您可以在“任务”标签页中开始任务。“crsTransform”“scale”和“dimensions”是互斥的。
用法 返回 Export.image.toDrive(image, description , folder , fileNamePrefix , dimensions , region , scale , crs , crsTransform , maxPixels , shardSize , fileDimensions , skipEmptyTiles , fileFormat , formatOptions , priority )
参数 类型 详细信息 image
图片 要导出的图片。 description
字符串,可选 任务的简明易懂的名称。可以包含字母、数字、-、_(不能包含空格)。默认为“myExportImageTask”。 folder
字符串,可选 导出文件将位于的 Google 云端硬盘文件夹。注意:(a) 如果文件夹名称存在于任何级别,则输出会写入该文件夹;(b) 如果存在重复的文件夹名称,则输出会写入最近修改的文件夹;(c) 如果文件夹名称不存在,则会在根目录中创建一个新文件夹;(d) 带有分隔符(例如“path/to/file”)的文件夹名称会被解读为字面字符串,而不是系统路径。默认为云端硬盘根目录。 fileNamePrefix
字符串,可选 文件名前缀。可以包含字母、数字、-、_(不能包含空格)。默认为说明。 dimensions
Number|String,可选 要用于导出图片的尺寸。接受单个正整数作为最大维度,或接受“WIDTHxHEIGHT”,其中 WIDTH 和 HEIGHT 均为正整数。 region
Geometry.LinearRing|Geometry.Polygon|String,可选 要导出的区域,以 LinearRing、Polygon 或坐标表示。这些值可以指定为 Geometry 对象或序列化为字符串的坐标。 scale
数字,可选 分辨率(以每像素米数为单位)。默认值为 1000。 crs
字符串,可选 要用于导出图片的 CRS。 crsTransform
List<Number>|String,可选 用于导出图像的仿射转换。需要定义“crs”。 maxPixels
数字,可选 限制导出中的像素数量。默认情况下,如果导出像素数超过 1 亿,您会看到一条错误消息。明确设置此值可提高或降低此限制。 shardSize
数字,可选 将计算此图片的图块的大小(以像素为单位)。默认值为 256。 fileDimensions
List<Number>|Number, optional 每个图片文件的像素尺寸(如果图片太大而无法放入单个文件中)。可以指定单个数字来表示正方形,也可以指定一个二维数组来表示(宽度、高度)。请注意,图片仍会剪裁为整体图片尺寸。必须是 shardSize 的倍数。 skipEmptyTiles
布尔值,可选 如果为 true,则跳过写入空白(即完全遮盖)图片块。默认值为 false。仅支持 GeoTIFF 导出格式。 fileFormat
字符串,可选 导出到的字符串文件格式。目前仅支持“GeoTIFF”和“TFRecord”,默认值为“GeoTIFF”。 formatOptions
ImageExportFormatConfig,可选 一个字典,包含字符串键和特定于格式的选项。对于“GeoTIFF”:“cloudOptimized”(布尔值)、“noData”(浮点数)。对于“TFRecord”:请参阅 https://developers.google.com/earth-engine/guides/tfrecord#formatoptions priority
数字,可选 任务在项目中的优先级。优先级较高的任务会更早安排。必须是介于 0 到 9999 之间的整数。默认值为 100。
示例
代码编辑器 (JavaScript)
// A Landsat 8 surface reflectance image.
var image = ee . Image ( 'LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508' )
. select ([ 'SR_B.' ]); // reflectance bands
// A region of interest.
var region = ee . Geometry . BBox ( - 122.24 , 37.13 , - 122.11 , 37.20 );
// Set the export "scale" and "crs" parameters.
Export . image . toDrive ({
image : image ,
description : 'image_export' ,
folder : 'ee_demos' ,
region : region ,
scale : 30 ,
crs : 'EPSG:5070'
});
// Use the "crsTransform" export parameter instead of "scale" for more control
// over the output grid. Here, "crsTransform" is set to align the output grid
// with the grid of another dataset. To view an image's CRS transform:
// print(image.projection())
Export . image . toDrive ({
image : image ,
description : 'image_export_crstransform' ,
folder : 'ee_demos' ,
region : region ,
crsTransform : [ 30 , 0 , - 2493045 , 0 , - 30 , 3310005 ],
crs : 'EPSG:5070'
});
// If the export has more than 1e8 pixels, set "maxPixels" higher.
Export . image . toDrive ({
image : image ,
description : 'image_export_maxpixels' ,
folder : 'ee_demos' ,
region : region ,
scale : 30 ,
crs : 'EPSG:5070' ,
maxPixels : 1e13
});
// Export a Cloud Optimized GeoTIFF (COG) by setting the "cloudOptimized"
// parameter to true.
Export . image . toDrive ({
image : image ,
description : 'image_export_cog' ,
folder : 'ee_demos' ,
region : region ,
scale : 30 ,
crs : 'EPSG:5070' ,
formatOptions : {
cloudOptimized : true
}
});
// Define a nodata value and replace masked pixels with it using "unmask".
// Set the "sameFootprint" parameter as "false" to include pixels outside of the
// image geometry in the unmasking operation.
var noDataVal = - 9999 ;
var unmaskedImage = image . unmask ({ value : noDataVal , sameFootprint : false });
// Use the "noData" key in the "formatOptions" parameter to set the nodata value
// (GeoTIFF format only).
Export . image . toDrive ({
image : unmaskedImage ,
description : 'image_export_nodata' ,
folder : 'ee_demos' ,
region : image . geometry (), // full image bounds
scale : 2000 , // large scale for minimal demo
crs : 'EPSG:5070' ,
fileFormat : 'GeoTIFF' ,
formatOptions : {
noData : noDataVal
}
});
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境 页面。
import ee
import geemap.core as geemap
Colab (Python)
# A Landsat 8 surface reflectance image.
image = ee . Image (
'LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508'
) . select ([ 'SR_B.' ]) # reflectance bands
# A region of interest.
region = ee . Geometry . BBox ( - 122.24 , 37.13 , - 122.11 , 37.20 )
# Set the export "scale" and "crs" parameters.
task = ee . batch . Export . image . toDrive (
image = image ,
description = 'image_export' ,
folder = 'ee_demos' ,
region = region ,
scale = 30 ,
crs = 'EPSG:5070'
)
task . start ()
# Use the "crsTransform" export parameter instead of "scale" for more control
# over the output grid. Here, "crsTransform" is set to align the output grid
# with the grid of another dataset. To view an image's CRS transform:
# print(image.projection().getInfo())
task = ee . batch . Export . image . toDrive (
image = image ,
description = 'image_export_crstransform' ,
folder = 'ee_demos' ,
region = region ,
crsTransform = [ 30 , 0 , - 2493045 , 0 , - 30 , 3310005 ],
crs = 'EPSG:5070'
)
task . start ()
# If the export has more than 1e8 pixels, set "maxPixels" higher.
task = ee . batch . Export . image . toDrive (
image = image ,
description = 'image_export_maxpixels' ,
folder = 'ee_demos' ,
region = region ,
scale = 30 ,
crs = 'EPSG:5070' ,
maxPixels = 1e13
)
task . start ()
# Export a Cloud Optimized GeoTIFF (COG) by setting the "cloudOptimized"
# parameter to true.
task = ee . batch . Export . image . toDrive (
image = image ,
description = 'image_export_cog' ,
folder = 'ee_demos' ,
region = region ,
scale = 30 ,
crs = 'EPSG:5070' ,
formatOptions = {
'cloudOptimized' : True
}
)
task . start ()
# Define a nodata value and replace masked pixels with it using "unmask".
# Set the "sameFootprint" parameter as "false" to include pixels outside of the
# image geometry in the unmasking operation.
nodata_val = - 9999
unmasked_image = image . unmask ( value = nodata_val , sameFootprint = False )
# Use the "noData" key in the "formatOptions" parameter to set the nodata value
# (GeoTIFF format only).
task = ee . batch . Export . image . toDrive (
image = unmasked_image ,
description = 'image_export_nodata' ,
folder = 'ee_demos' ,
region = image . geometry (), # full image bounds
scale = 2000 , # large scale for minimal demo
crs = 'EPSG:5070' ,
fileFormat = 'GeoTIFF' ,
formatOptions = {
'noData' : nodata_val
}
)
task . start ()
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
需要向我们提供更多信息?
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-25。"],[[["This function exports an Earth Engine image as a raster to your Google Drive."],["You can customize the export by specifying parameters like file name, folder, region, scale, and projection."],["For large exports, you can control the tiling and pixel limits using parameters like `maxPixels`, `shardSize`, and `fileDimensions`."],["GeoTIFF and TFRecord are the supported export file formats with options for compression and NoData values."],["Tasks are initiated from the 'Tasks' tab in the Earth Engine Code Editor and can be monitored for progress and completion."]]],["This creates a batch task to export an image as a raster to Google Drive. Key parameters include the `image`, `description`, `folder`, `fileNamePrefix`, and `region`. Users can define `dimensions`, `scale`, `crs`, or `crsTransform` for output customization; these options are mutually exclusive. Additional settings involve `maxPixels`, `shardSize`, `fileDimensions`, `skipEmptyTiles`, `fileFormat`, `formatOptions`, and `priority`. Tasks can be initiated from the Tasks tab, allowing for control over the exported raster's properties and storage location.\n"]]