Export.image.toCloudStorage

Crea un'attività batch per esportare un'immagine come raster in Google Cloud Storage. Le attività possono essere avviate dalla scheda Attività.

"crsTransform", "scale" e "dimensions" si escludono a vicenda.

UtilizzoResi
Export.image.toCloudStorage(image, description, bucket, fileNamePrefix, dimensions, region, scale, crs, crsTransform, maxPixels, shardSize, fileDimensions, skipEmptyTiles, fileFormat, formatOptions, priority)
ArgomentoTipoDettagli
imageImmagineL'immagine da esportare.
descriptionStringa, facoltativaUn nome leggibile dell'attività. Il valore predefinito è "myExportImageTask".
bucketStringa, facoltativaIl bucket di destinazione di Cloud Storage.
fileNamePrefixStringa, facoltativaLa stringa utilizzata come prefisso dell'output. Una "/" finale indica un percorso. Il valore predefinito è la descrizione dell'attività.
dimensionsNumero|Stringa, facoltativaLe dimensioni da utilizzare per l'immagine esportata. Accetta un singolo numero intero positivo come dimensione massima o "WIDTHxHEIGHT", dove WIDTH e HEIGHT sono numeri interi positivi.
regionGeometry.LinearRing|Geometry.Polygon|Stringa, facoltativaUn LinearRing, un poligono o coordinate che rappresentano la regione da esportare. Questi possono essere specificati come oggetti Geometry o coordinate serializzate come stringa.
scaleNumero, facoltativoRisoluzione in metri per pixel. Il valore predefinito è 1000.
crsStringa, facoltativaIl CRS da utilizzare per l'immagine esportata.
crsTransformList[Number]|Stringa, facoltativaLa trasformazione affine da utilizzare per l'immagine esportata. Richiede la definizione di "crs".
maxPixelsNumero, facoltativoLimita il numero di pixel nell'esportazione. Per impostazione predefinita, viene visualizzato un errore se l'esportazione supera 1e8 pixel. L'impostazione esplicita di questo valore consente di aumentare o diminuire questo limite.
shardSizeNumero, facoltativoLe dimensioni in pixel dei riquadri in cui verrà calcolata questa immagine. Il valore predefinito è 256.
fileDimensionsList[Number]|Numero, facoltativoLe dimensioni in pixel di ogni file immagine, se l'immagine è troppo grande per essere contenuta in un singolo file. Puoi specificare un singolo numero per indicare una forma quadrata o un array di due dimensioni per indicare (larghezza, altezza). Tieni presente che l'immagine verrà comunque ritagliata in base alle dimensioni complessive dell'immagine. Deve essere un multiplo di shardSize.
skipEmptyTilesBooleano, facoltativoSe è true, salta la scrittura dei riquadri immagine vuoti (ovvero completamente mascherati). Il valore predefinito è false. Supportato solo per le esportazioni GeoTIFF.
fileFormatStringa, facoltativaIl formato file stringa in cui viene esportata l'immagine. Al momento sono supportati solo "GeoTIFF" e "TFRecord", il valore predefinito è "GeoTIFF".
formatOptionsImageExportFormatConfig, facoltativoUn dizionario di chiavi stringa per le opzioni specifiche del formato. Per "GeoTIFF": "cloudOptimized" (booleano), "noData" (float). Per "TFRecord": vedi https://developers.google.com/earth-engine/guides/tfrecord#formatoptions
priorityNumero, facoltativoLa priorità dell'attività all'interno del progetto. Le attività con priorità più alta vengono pianificate prima. Deve essere un numero intero compreso tra 0 e 9999. Il valore predefinito è 100.

Esempi

Editor di codice (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.toCloudStorage({
  image: image,
  description: 'image_export',
  bucket: 'gcs-bucket-name',
  fileNamePrefix: 'image_export',
  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.toCloudStorage({
  image: image,
  description: 'image_export_crstransform',
  bucket: 'gcs-bucket-name',
  fileNamePrefix: 'image_export_crstransform',
  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.toCloudStorage({
  image: image,
  description: 'image_export_maxpixels',
  bucket: 'gcs-bucket-name',
  fileNamePrefix: 'image_export_maxpixels',
  region: region,
  scale: 30,
  crs: 'EPSG:5070',
  maxPixels: 1e13
});

// Export a Cloud Optimized GeoTIFF (COG) by setting the "cloudOptimized"
// parameter to true.
Export.image.toCloudStorage({
  image: image,
  description: 'image_export_cog',
  bucket: 'gcs-bucket-name',
  fileNamePrefix: 'image_export_cog',
  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.toCloudStorage({
  image: unmaskedImage,
  description: 'image_export_nodata',
  bucket: 'gcs-bucket-name',
  fileNamePrefix: 'image_export_nodata',
  region: image.geometry(),  // full image bounds
  scale: 2000,  // large scale for minimal demo
  crs: 'EPSG:5070',
  fileFormat: 'GeoTIFF',
  formatOptions: {
    noData: noDataVal
  }
});

Configurazione di Python

Per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo, consulta la pagina Ambiente 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.toCloudStorage(
    image=image,
    description='image_export',
    bucket='gcs-bucket-name',
    fileNamePrefix='image_export',
    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:
# display(image.projection())
task = ee.batch.Export.image.toCloudStorage(
    image=image,
    description='image_export_crstransform',
    bucket='gcs-bucket-name',
    fileNamePrefix='image_export_crstransform',
    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.toCloudStorage(
    image=image,
    description='image_export_maxpixels',
    bucket='gcs-bucket-name',
    fileNamePrefix='image_export_maxpixels',
    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.toCloudStorage(
    image=image,
    description='image_export_cog',
    bucket='gcs-bucket-name',
    fileNamePrefix='image_export_cog',
    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.toCloudStorage(
    image=unmasked_image,
    description='image_export_nodata',
    bucket='gcs-bucket-name',
    fileNamePrefix='image_export_nodata',
    region=image.geometry(),  # full image bounds
    scale=2000,  # large scale for minimal demo
    crs='EPSG:5070',
    fileFormat='GeoTIFF',
    formatOptions={
       'noData': nodata_val
    }
)
task.start()