Vous pouvez exporter un FeatureCollection au format CSV, SHP (shapefile), GeoJSON, KML, KMZ ou TFRecord à l'aide de Export.table. FeatureCollection peut représenter des vecteurs ou simplement une table de données. Dans ce dernier cas, les éléments de la collection auront une géométrie nulle.
Notez certaines contraintes supplémentaires lorsque vous travaillez avec certains formats de fichiers, y compris :
- KML : un
FeatureCollectionexporté vers un fichier KML verra toutes ses géométries transformées en coordonnées non projetées (WGS84). - SHP : un
FeatureCollectionexporté vers un fichier Shapefile doit contenir des éléments géographiques avec le même type de géométrie et la même projection, et doit respecter les limites de taille des fichiers Shapefile. Les noms de colonnes sont tronqués à 10 caractères ou moins, et cela ne doit pas créer de noms de colonnes en double. - TFRecord : consultez la page Format de données TFRecord.
vers Cloud Storage
Pour exporter un FeatureCollection vers Cloud Storage, utilisez Export.table.toCloudStorage(). Par exemple, en utilisant le features défini précédemment :
Éditeur de code (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()
en élément
Pour exporter un FeatureCollection en tant qu'élément Earth Engine, utilisez Export.table.toAsset(). Par exemple, en utilisant le features défini précédemment :
Éditeur de code (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()
La taille et la forme des éléments de table Earth Engine sont soumises à plusieurs limites :
- 100 millions de caractéristiques au maximum
- 1 000 propriétés (colonnes) au maximum
- 100 000 sommets maximum pour la géométrie de chaque ligne
- 100 000 caractères maximum par valeur de chaîne
vers BigQuery
Vous pouvez exporter un FeatureCollection vers une table BigQuery à l'aide de Export.table.toBigQuery().
Cela vous permet d'intégrer vos données Earth Engine à d'autres données et outils disponibles dans BigQuery. Pour en savoir plus, consultez le guide d'exportation vers BigQuery.
Éditeur de code (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()
dans Drive
Pour exporter un FeatureCollection vers votre compte Drive, utilisez Export.table.toDrive(). Exemple :
Éditeur de code (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()
Notez que le format de sortie est spécifié en tant que KML pour gérer les données géographiques (SHP serait également approprié pour exporter une table avec une géométrie). Pour exporter uniquement un tableau de données, sans aucune information géographique, exportez les éléments avec une géométrie nulle au format CSV. L'exemple suivant montre comment utiliser Export.table.toDrive() pour obtenir les résultats d'une réduction potentiellement longue :
Éditeur de code (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()
Notez que le format est défini sur "CSV" dans cet exemple, car il n'y a pas de géométrie dans le résultat.