Export.image.toAsset

创建批量任务,以将映像作为栅格导出到 Earth Engine 资产。您可以在“任务”标签页中开始任务。

用法返回
Export.image.toAsset(image, description, assetId, pyramidingPolicy, dimensions, region, scale, crs, crsTransform, maxPixels, shardSize, priority)
参数类型详细信息
image图片要导出的图片。
description字符串,可选任务的简明易懂的名称。默认为“myExportImageTask”。
assetId字符串,可选目标素材资源 ID。
pyramidingPolicy对象,可选要应用于图像中每个波段的层叠政策,按波段名称进行键控。值必须是以下之一:平均值、样本、最小值、最大值或众数。默认值为“mean”。您可以使用特殊键“.default”来更改所有频段的默认值。
dimensionsNumber|String,可选要用于导出图片的尺寸。接受单个正整数作为最大维度,或接受“WIDTHxHEIGHT”(其中 WIDTH 和 HEIGHT 均为正整数)。
regionGeometry.LinearRing|Geometry.Polygon|String,可选要导出的区域,以 LinearRing、Polygon 或坐标表示。这些值可以指定为 Geometry 对象或序列化为字符串的坐标。
scale数字,可选分辨率(以每像素米数为单位)。默认值为 1000。
crs字符串,可选要用于导出图片的 CRS。
crsTransformList<Number>|String,可选用于导出图像的仿射转换。需要定义“crs”。
maxPixels数字,可选限制导出中的像素数量。默认情况下,如果导出像素数超过 1 亿,您会看到一条错误消息。明确设置此值可提高或降低此限制。
shardSize数字,可选将计算此图片的图块的大小(以像素为单位)。默认值为 256。
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.toAsset({
  image: image,
  description: 'image_export',
  assetId: 'projects/<project-name>/assets/<asset-name>',  // <> modify these
  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.toAsset({
  image: image,
  description: 'image_export_crstransform',
  assetId: 'projects/<project-name>/assets/<asset-name>',  // <> modify these
  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.toAsset({
  image: image,
  description: 'image_export_maxpixels',
  assetId: 'projects/<project-name>/assets/<asset-name>',  // <> modify these
  region: region,
  scale: 30,
  crs: 'EPSG:5070',
  maxPixels: 1e13
});

// The default "pyramidingPolicy" is mean. If data are categorical,
// consider mode.
Export.image.toAsset({
  image: image.select('SR_B5'),
  description: 'image_export_pyramiding',
  assetId: 'projects/<project-name>/assets/<asset-name>',  // <> modify these
  region: region,
  scale: 30,
  crs: 'EPSG:5070',
  pyramidingPolicy: {SR_B5: 'mode'}
});

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.toAsset(
    image=image,
    description='image_export',
    assetId='projects/<project-name>/assets/<asset-name>',  # <> modify these
    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.toAsset(
    image=image,
    description='image_export_crstransform',
    assetId='projects/<project-name>/assets/<asset-name>',  # <> modify these
    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.toAsset(
    image=image,
    description='image_export_maxpixels',
    assetId='projects/<project-name>/assets/<asset-name>',  # <> modify these
    region=region,
    scale=30,
    crs='EPSG:5070',
    maxPixels=1e13
)
task.start()

# The default "pyramidingPolicy" is mean. If data are categorical,
# consider mode.
task = ee.batch.Export.image.toAsset(
    image=image.select('SR_B5'),
    description='image_export_pyramiding',
    assetId='projects/<project-name>/assets/<asset-name>',  # <> modify these
    region=region,
    scale=30,
    crs='EPSG:5070',
    pyramidingPolicy={'SR_B5': 'mode'}
)
task.start()