Export.image.toDrive
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo một tác vụ hàng loạt để xuất Hình ảnh dưới dạng một hình ảnh raster sang Drive. Bạn có thể bắt đầu việc cần làm từ thẻ Tasks. "crsTransform", "scale" và "dimensions" là các thuộc tính loại trừ lẫn nhau.
Cách sử dụng | Giá trị trả về |
---|
Export.image.toDrive(image, description, folder, fileNamePrefix, dimensions, region, scale, crs, crsTransform, maxPixels, shardSize, fileDimensions, skipEmptyTiles, fileFormat, formatOptions, priority) | |
Đối số | Loại | Thông tin chi tiết |
---|
image | Hình ảnh | Hình ảnh cần xuất. |
description | Chuỗi, không bắt buộc | Tên dễ đọc của việc cần làm. Có thể chứa chữ cái, số, dấu gạch ngang, dấu gạch dưới (không có dấu cách). Giá trị mặc định là "myExportImageTask". |
folder | Chuỗi, không bắt buộc | Thư mục trên Google Drive nơi tệp xuất sẽ được lưu trữ. Lưu ý: (a) nếu tên thư mục tồn tại ở bất kỳ cấp độ nào, đầu ra sẽ được ghi vào đó, (b) nếu có tên thư mục trùng lặp, đầu ra sẽ được ghi vào thư mục được sửa đổi gần đây nhất, (c) nếu tên thư mục không tồn tại, một thư mục mới sẽ được tạo ở thư mục gốc và (d) tên thư mục có dấu phân cách (ví dụ: "path/to/file") được hiểu là chuỗi ký tự chứ không phải đường dẫn hệ thống. Giá trị mặc định là thư mục gốc của Drive. |
fileNamePrefix | Chuỗi, không bắt buộc | Tiền tố tên tệp. Có thể chứa chữ cái, số, dấu gạch ngang, dấu gạch dưới (không có dấu cách). Giá trị mặc định là nội dung mô tả. |
dimensions | Number|String, không bắt buộc | Kích thước dùng cho hình ảnh được xuất. Lấy một số nguyên dương duy nhất làm kích thước tối đa hoặc "WIDTHxHEIGHT", trong đó WIDTH và HEIGHT đều là số nguyên dương. |
region | Geometry.LinearRing|Geometry.Polygon|String, không bắt buộc | LinearRing, Polygon hoặc toạ độ đại diện cho khu vực cần xuất. Bạn có thể chỉ định các đối tượng này dưới dạng đối tượng Hình học hoặc toạ độ được chuyển đổi tuần tự thành một chuỗi. |
scale | Số, không bắt buộc | Độ phân giải tính bằng mét trên mỗi pixel. Giá trị mặc định là 1000. |
crs | Chuỗi, không bắt buộc | CRS sẽ dùng cho hình ảnh được xuất. |
crsTransform | List<Number>|String, optional | Phép biến đổi affine dùng cho hình ảnh được xuất. Yêu cầu bạn xác định "crs". |
maxPixels | Số, không bắt buộc | Hạn chế số lượng pixel trong tệp xuất. Theo mặc định, bạn sẽ thấy lỗi nếu dữ liệu xuất vượt quá 100 triệu pixel. Việc đặt giá trị này một cách rõ ràng cho phép bạn tăng hoặc giảm giới hạn này. |
shardSize | Số, không bắt buộc | Kích thước tính bằng pixel của các ô mà hình ảnh này sẽ được tính toán. Giá trị mặc định là 256. |
fileDimensions | List<Number>|Number, optional | Kích thước (tính bằng pixel) của mỗi tệp hình ảnh, nếu hình ảnh quá lớn để vừa trong một tệp. Có thể chỉ định một số duy nhất để biểu thị hình vuông hoặc một mảng gồm 2 chiều để biểu thị (chiều rộng, chiều cao). Xin lưu ý rằng hình ảnh vẫn sẽ bị cắt theo kích thước tổng thể của hình ảnh. Phải là bội số của shardSize. |
skipEmptyTiles | Boolean, không bắt buộc | Nếu là true, hãy bỏ qua việc ghi các ô hình ảnh trống (tức là được che hoàn toàn). Giá trị mặc định là false. Chỉ được hỗ trợ trên các tệp xuất GeoTIFF. |
fileFormat | Chuỗi, không bắt buộc | Định dạng tệp chuỗi mà hình ảnh được xuất sang. Hiện tại, chỉ có "GeoTIFF" và "TFRecord" được hỗ trợ, mặc định là "GeoTIFF". |
formatOptions | ImageExportFormatConfig (không bắt buộc) | Từ điển gồm các khoá chuỗi cho các lựa chọn cụ thể theo định dạng. Đối với "GeoTIFF": "cloudOptimized" (Boolean), "noData" (float). Đối với "TFRecord": hãy xem https://developers.google.com/earth-engine/guides/tfrecord#formatoptions |
priority | Số, không bắt buộc | Mức độ ưu tiên của công việc trong dự án. Các công việc có mức độ ưu tiên cao hơn sẽ được lên lịch sớm hơn. Phải là số nguyên từ 0 đến 9999. Giá trị mặc định là 100. |
Ví dụ
Trình soạn thảo mã (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
}
});
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap
cho quá trình phát triển tương tác.
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()
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eThis function exports an Earth Engine image as a raster to your Google Drive.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the export by specifying parameters like file name, folder, region, scale, and projection.\u003c/p\u003e\n"],["\u003cp\u003eFor large exports, you can control the tiling and pixel limits using parameters like \u003ccode\u003emaxPixels\u003c/code\u003e, \u003ccode\u003eshardSize\u003c/code\u003e, and \u003ccode\u003efileDimensions\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eGeoTIFF and TFRecord are the supported export file formats with options for compression and NoData values.\u003c/p\u003e\n"],["\u003cp\u003eTasks are initiated from the 'Tasks' tab in the Earth Engine Code Editor and can be monitored for progress and completion.\u003c/p\u003e\n"]]],["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"],null,[]]