Tabellen- und Vektordaten exportieren

Mit Export.table können Sie eine FeatureCollection als CSV-, SHP- (Shapefile), GeoJSON-, KML-, KMZ- oder TFRecord-Datei exportieren. FeatureCollection kann Vektoren oder einfach eine Datentabelle darstellen. In letzterem Fall haben die Elemente in der Sammlung keine Geometrie.

Beachten Sie bei der Arbeit mit einigen Dateiformaten die folgenden zusätzlichen Einschränkungen:

  • KML: Bei einer FeatureCollection, die in eine KML-Datei exportiert wird, werden alle Geometrien in nicht projizierte (WGS84) Koordinaten umgewandelt.
  • SHP: Ein in ein Shapefile exportiertes FeatureCollection muss Features mit demselben Geometriestyp und derselben Projektion enthalten und die Größenbeschränkungen für Shapefiles einhalten. Spaltennamen werden auf maximal 10 Zeichen gekürzt. Dabei dürfen keine doppelten Spaltennamen entstehen.
  • TFRecord: Weitere Informationen

zu Drive

Wenn Sie eine FeatureCollection in Ihr Drive-Konto exportieren möchten, verwenden Sie Export.table.toDrive(). Beispiel:

// 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 the FeatureCollection to a KML file.
Export.table.toDrive({
  collection: features,
  description:'vectorsToDriveExample',
  fileFormat: 'KML'
});

Auf der Seite Python-Umgebung finden Sie Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung.

import ee
import geemap.core as geemap
# 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 the FeatureCollection to a KML file.
task = ee.batch.Export.table.toDrive(
    collection=features, description='vectorsToDriveExample', fileFormat='KML'
)
task.start()

Das Ausgabeformat ist KML, um geografische Daten zu verarbeiten. SHP ist auch für den Export einer Tabelle mit Geometrie geeignet. Wenn Sie nur eine Datentabelle ohne geografische Informationen exportieren möchten, exportieren Sie Elemente mit Nullgeometrie im CSV-Format. Im folgenden Beispiel wird gezeigt, wie mit Export.table.toDrive() die Ergebnisse einer potenziell langwierigen Reduzierung abgerufen werden:

// 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'
});

Auf der Seite Python-Umgebung finden Sie Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung.

import ee
import geemap.core as geemap
# 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()

In diesem Beispiel ist das Format auf „CSV“ festgelegt, da die Ausgabe keine Geometrie enthält.

zu Cloud Storage

Verwenden Sie Export.table.toCloudStorage(), um eine FeatureCollection nach Cloud Storage zu exportieren. Beispiel: Verwenden Sie features, das Sie zuvor definiert haben:

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

Auf der Seite Python-Umgebung finden Sie Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung.

import ee
import geemap.core as geemap
# 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()

zu Asset

Wenn Sie eine FeatureCollection als Earth Engine-Asset exportieren möchten, verwenden Sie Export.table.toAsset(). Verwenden Sie beispielsweise den zuvor definierten features:

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

Auf der Seite Python-Umgebung finden Sie Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung.

import ee
import geemap.core as geemap
# 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()

Für die Größe und Form von Earth Engine-Tabellen-Assets gelten mehrere Einschränkungen:

  • Maximal 100 Millionen Elemente
  • Maximal 1.000 Properties (Spalten)
  • Maximal 100.000 Ecken für die Geometrie jeder Zeile
  • Maximal 100.000 Zeichen pro Stringwert