Mengekspor data tabel dan vektor

Anda dapat mengekspor FeatureCollection sebagai CSV, SHP (shapefile), GeoJSON, KML, KMZ, atau TFRecord menggunakan Export.table. FeatureCollection dapat mewakili vektor atau sekadar tabel data. Dalam kasus yang terakhir, fitur dalam koleksi akan memiliki geometri null.

Perhatikan beberapa batasan tambahan saat menggunakan beberapa format file, termasuk:

  • KML: FeatureCollection yang diekspor ke file KML akan memiliki semua geometri yang diubah menjadi koordinat yang tidak diproyeksikan (WGS84).
  • SHP: FeatureCollection yang diekspor ke Shapefile harus berisi fitur dengan jenis dan proyeksi geometri yang sama serta harus sesuai dengan batas ukuran Shapefile. Nama kolom dipotong menjadi 10 karakter atau kurang, dan hal ini tidak boleh membuat nama kolom duplikat.
  • TFRecord: Lihat halaman Format data TFRecord.

ke Cloud Storage

Untuk mengekspor FeatureCollection ke Cloud Storage, gunakan Export.table.toCloudStorage(). Misalnya, menggunakan features yang ditentukan sebelumnya:

Editor Kode (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'
});

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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()

ke Aset

Untuk mengekspor FeatureCollection sebagai aset Earth Engine, gunakan Export.table.toAsset(). Misalnya, menggunakan features yang ditentukan sebelumnya:

Editor Kode (JavaScript)

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

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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()

Ada beberapa batasan pada ukuran dan bentuk aset tabel Earth Engine:

  • Maksimum 100 juta fitur
  • Maksimum 1.000 properti (kolom)
  • Maksimum 100.000 verteks untuk geometri setiap baris
  • Maksimum 100.000 karakter per nilai string

ke BigQuery

Anda dapat mengekspor FeatureCollection ke tabel BigQuery menggunakan Export.table.toBigQuery(). Dengan begitu, Anda dapat mengintegrasikan data Earth Engine dengan data dan alat lain yang tersedia di BigQuery. Untuk mengetahui informasi selengkapnya, lihat panduan Mengekspor ke BigQuery.

Editor Kode (JavaScript)

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

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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()

ke Drive

Untuk mengekspor FeatureCollection ke akun Drive Anda, gunakan Export.table.toDrive(). Contoh:

Editor Kode (JavaScript)

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

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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()

Perhatikan bahwa format output ditentukan sebagai KML untuk menangani data geografis (SHP juga sesuai untuk mengekspor tabel dengan geometri). Untuk mengekspor tabel data saja, tanpa informasi geografis, ekspor fitur dengan geometri null dalam format CSV. Berikut ini menunjukkan penggunaan Export.table.toDrive() untuk mendapatkan hasil pengurangan yang berpotensi berjalan lama:

Editor Kode (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'
});

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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()

Perhatikan bahwa format ditetapkan ke 'CSV' dalam contoh ini karena tidak ada geometri dalam output.