Puedes exportar un FeatureCollection
como CSV, SHP (Shapefile), GeoJSON, KML, KMZ o TFRecord con Export.table
. FeatureCollection
puede representar vectores o simplemente una tabla de datos. En el último caso, los componentes de la colección tendrán una geometría nula.
Ten en cuenta algunas restricciones adicionales cuando trabajes con algunos formatos de archivo, incluidos los siguientes:
- KML: Un
FeatureCollection
exportado a un archivo KML tendrá todas las geometrías transformadas a coordenadas sin proyectar (WGS84). - SHP: Un
FeatureCollection
exportado a un archivo Shapefile debe contener componentes con el mismo tipo de geometría y proyección, y debe ajustarse a los límites de tamaño de Shapefile. Los nombres de las columnas se truncan a 10 caracteres o menos, y esto no debe crear nombres de columnas duplicados. - TFRecord: Consulta esta página.
a Cloud Storage
Para exportar un FeatureCollection
a Cloud Storage, usa Export.table.toCloudStorage()
. Por ejemplo, con el features
definido anteriormente:
Editor de código (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' });
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()
a Asset
Para exportar un FeatureCollection
como un recurso de Earth Engine, usa Export.table.toAsset()
. Por ejemplo, con el features
definido anteriormente:
Editor de código (JavaScript)
// Export an ee.FeatureCollection as an Earth Engine asset. Export.table.toAsset({ collection: features, description:'exportToTableAssetExample', assetId: 'exampleAssetId', });
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()
Existen varias limitaciones en el tamaño y la forma de los recursos de tablas de Earth Engine:
- Un máximo de 100 millones de componentes
- Un máximo de 1,000 propiedades (columnas)
- Un máximo de 100,000 vértices para la geometría de cada fila
- Un máximo de 100,000 caracteres por valor de cadena
a BigQuery
Puedes exportar un FeatureCollection
a una tabla de BigQuery con Export.table.toBigQuery()
.
Esto te permite integrar tus datos de Earth Engine con otros datos y herramientas disponibles en BigQuery. Para obtener más información, consulta la guía de exportación a BigQuery.
Editor de código (JavaScript)
Export.table.toBigQuery({ collection: features, table: 'myproject.mydataset.mytable', description: 'put_my_data_in_bigquery', append: true, overwrite: false });
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()
a Drive
Para exportar un FeatureCollection
a tu cuenta de Drive, usa Export.table.toDrive()
. Por ejemplo:
Editor de código (JavaScript)
// Export the FeatureCollection to a KML file. Export.table.toDrive({ collection: features, description:'vectorsToDriveExample', fileFormat: 'KML' });
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()
Ten en cuenta que el formato de salida se especifica como KML para controlar los datos geográficos (SHP también sería apropiado para exportar una tabla con geometría). Para exportar solo una tabla de datos, sin información geográfica, exporta componentes con geometría nula en formato CSV. En el siguiente ejemplo, se muestra el uso de Export.table.toDrive()
para obtener los resultados de una reducción potencialmente de larga duración:
Editor de código (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' });
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()
Ten en cuenta que el formato se establece en “CSV” en este ejemplo, ya que no hay geometría en el resultado.