É possível exportar um FeatureCollection
como CSV, SHP (shapefile), GeoJSON, KML, KMZ ou TFRecord usando Export.table
. O FeatureCollection
pode representar vetores
ou simplesmente uma tabela de dados. Nesse último caso, os elementos na coleção terão geometria nula.
Observe algumas restrições adicionais ao trabalhar com alguns formatos de arquivo, incluindo:
- KML: um
FeatureCollection
exportado para um arquivo KML terá todas as geometrias transformadas em coordenadas não projetadas (WGS84). - SHP: um
FeatureCollection
exportado para um shapefile precisa conter elementos com o mesmo tipo de geometria e projeção e se encaixar nos limites de tamanho do shapefile. Os nomes de colunas são truncados para 10 caracteres ou menos e não podem criar nomes de colunas duplicados. - TFRecord: consulte esta página.
para o Drive
Para exportar um FeatureCollection
para sua conta do Drive, use
Export.table.toDrive()
. Exemplo:
// 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' });
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()
O formato de saída é especificado como KML para processar dados geográficos. O SHP também é adequado para exportar uma tabela com geometria. Para exportar apenas uma tabela de dados, sem informações geográficas, exporte elementos com geometria nula no formato CSV. O exemplo a seguir demonstra o uso de
Export.table.toDrive()
para receber os resultados de uma redução
de execução potencialmente longa:
// 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
# 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()
O formato está definido como "CSV" neste exemplo, já que não há geometria na saída.
para o Cloud Storage
Para exportar um FeatureCollection
para o Cloud Storage, use
Export.table.toCloudStorage()
. Por exemplo, usando o features
definido
anteriormente:
// 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
# 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()
para "Recurso"
Para exportar um FeatureCollection
como um recurso do Earth Engine, use
Export.table.toAsset()
. Por exemplo, usando o features
definido anteriormente:
// 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
# 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()
Há várias limitações no tamanho e na forma dos recursos de tabela do Earth Engine:
- Máximo de 100 milhões de recursos
- Máximo de 1.000 propriedades (colunas)
- Máximo de 100.000 vértices para a geometria de cada linha
- Máximo de 100.000 caracteres por valor de string