Esporta i dati di tabelle e vettori

Puoi esportare un FeatureCollection in formato CSV, SHP (shapefile), GeoJSON, KML, KMZ o TFRecord utilizzando Export.table. FeatureCollection può rappresentare vettori o semplicemente una tabella di dati. In quest'ultimo caso, le caratteristiche della raccolta avranno una geometria null.

Tieni presente alcuni vincoli aggiuntivi quando lavori con alcuni formati file, tra cui:

  • KML: una FeatureCollection esportata in un file KML avrà tutte le geometrie trasformate in coordinate non proiettate (WGS84).
  • SHP: un FeatureCollection esportato in uno shapefile deve contenere elementi con lo stesso tipo di geometria e proiezione e deve rientrare nei limiti di dimensioni dello shapefile. I nomi delle colonne vengono troncati a 10 caratteri o meno e questo non deve creare nomi di colonne duplicati.
  • TFRecord: consulta la pagina Formato dei dati TFRecord.

su Cloud Storage

Per esportare un FeatureCollection in Cloud Storage, utilizza Export.table.toCloudStorage(). Ad esempio, utilizzando features definito in precedenza:

Editor di codice (JavaScript)

// Make a collection of points.
var features = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(30.41, 59.933), {name: 'Voronoi'}),
  ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}),
  ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'})
]);

// Export a KML file to Cloud Storage.
Export.table.toCloudStorage({
  collection: features,
  description:'vectorsToCloudStorageExample',
  bucket: 'your-bucket-name',
  fileNamePrefix: 'exampleTableExport',
  fileFormat: 'KML'
});

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

# Make a collection of points.
features = ee.FeatureCollection([
    ee.Feature(ee.Geometry.Point(30.41, 59.933), {'name': 'Voronoi'}),
    ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}),
    ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}),
])

# Export a KML file to Cloud Storage.
task = ee.batch.Export.table.toCloudStorage(
    collection=features,
    description='vectorsToCloudStorageExample',
    bucket='your-bucket-name',
    fileNamePrefix='exampleTableExport',
    fileFormat='KML',
)
task.start()

all'asset

Per esportare un FeatureCollection come asset Earth Engine, utilizza Export.table.toAsset(). Ad esempio, utilizzando il features definito in precedenza:

Editor di codice (JavaScript)

// Export an ee.FeatureCollection as an Earth Engine asset.
Export.table.toAsset({
  collection: features,
  description:'exportToTableAssetExample',
  assetId: 'exampleAssetId',
});

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

# Export an ee.FeatureCollection as an Earth Engine asset.
task = ee.batch.Export.table.toAsset(
    collection=features,
    description='exportToTableAssetExample',
    assetId='projects/your-project/assets/exampleAssetId',
)
task.start()

Esistono diverse limitazioni relative alle dimensioni e alla forma degli asset di tabelle di Earth Engine:

  • Massimo 100 milioni di caratteristiche
  • Massimo 1000 proprietà (colonne)
  • Massimo 100.000 vertici per la geometria di ogni riga
  • Massimo 100.000 caratteri per valore di stringa

in BigQuery

Puoi esportare un FeatureCollection in una tabella BigQuery utilizzando Export.table.toBigQuery(). In questo modo puoi integrare i dati di Earth Engine con altri dati e strumenti disponibili in BigQuery. Per saperne di più, consulta la guida all'esportazione in BigQuery.

Editor di codice (JavaScript)

Export.table.toBigQuery({
  collection: features,
  table: 'myproject.mydataset.mytable',
  description: 'put_my_data_in_bigquery',
  append: true,
  overwrite: false
});

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

task = ee.batch.Export.table.toBigQuery(
    collection=features,
    table='myproject.mydataset.mytable',
    description='put_my_data_in_bigquery',
    append=True,
    overwrite=False,
)
task.start()

su Drive

Per esportare un FeatureCollection nel tuo account Drive, utilizza Export.table.toDrive(). Ad esempio:

Editor di codice (JavaScript)

// Export the FeatureCollection to a KML file.
Export.table.toDrive({
  collection: features,
  description:'vectorsToDriveExample',
  fileFormat: 'KML'
});

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

# Export the FeatureCollection to a KML file.
task = ee.batch.Export.table.toDrive(
    collection=features, description='vectorsToDriveExample', fileFormat='KML'
)
task.start()

Tieni presente che il formato di output è specificato come KML per gestire i dati geografici (anche SHP sarebbe appropriato per esportare una tabella con geometria). Per esportare solo una tabella di dati, senza informazioni geografiche, esporta le caratteristiche con geometria null in formato CSV. Di seguito viene mostrato l'utilizzo di Export.table.toDrive() per ottenere i risultati di una riduzione potenzialmente a lunga esecuzione:

Editor di codice (JavaScript)

// Load a Landsat image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');
var projection = image.select('B2').projection().getInfo();

// Create an arbitrary rectangle.
var region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413);

// Get a dictionary of means in the region.
var means = image.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: region,
  crs: projection.crs,
  crsTransform: projection.transform,
});

// Make a feature without geometry and set the properties to the dictionary of means.
var feature = ee.Feature(null, means);

// Wrap the Feature in a FeatureCollection for export.
var featureCollection = ee.FeatureCollection([feature]);

// Export the FeatureCollection.
Export.table.toDrive({
  collection: featureCollection,
  description: 'exportTableExample',
  fileFormat: 'CSV'
});

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

# Load a Landsat image.
image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')
projection = image.select('B2').projection().getInfo()

# Create an arbitrary rectangle.
region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413)

# Get a dictionary of means in the region.
means = image.reduceRegion(
    reducer=ee.Reducer.mean(),
    geometry=region,
    crs=projection['crs'],
    crsTransform=projection['transform'],
)

# Make a feature without geometry and set the properties to the dictionary of means.
feature = ee.Feature(None, means)

# Wrap the Feature in a FeatureCollection for export.
feature_collection = ee.FeatureCollection([feature])

# Export the FeatureCollection.
task = ee.batch.Export.table.toDrive(
    collection=feature_collection,
    description='exportTableExample',
    fileFormat='CSV',
)
task.start()

Tieni presente che in questo esempio il formato è impostato su "CSV" perché non è presente alcuna geometria nell'output.