Export.table.toDrive
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Crée une tâche par lot pour exporter une FeatureCollection sous forme de tableau vers Drive. Vous pouvez lancer des tâches depuis l'onglet "Tâches".
Utilisation | Renvoie |
---|
Export.table.toDrive(collection, description, folder, fileNamePrefix, fileFormat, selectors, maxVertices, priority) | |
Argument | Type | Détails |
---|
collection | FeatureCollection | Collection d'entités à exporter. |
description | Chaîne, facultative | Nom de la tâche lisible par l'utilisateur. Peut contenir des lettres, des chiffres, -, _ (pas d'espaces). La valeur par défaut est "myExportTableTask". |
folder | Chaîne, facultative | Dossier Google Drive dans lequel l'exportation sera placée. Remarque : (a) si le nom du dossier existe à un niveau quelconque, le résultat y est écrit ; (b) si des noms de dossiers en double existent, le résultat est écrit dans le dossier modifié le plus récemment ; (c) si le nom du dossier n'existe pas, un nouveau dossier est créé à la racine ; (d) les noms de dossiers avec des séparateurs (par exemple, "path/to/file") sont interprétés comme des chaînes littérales, et non comme des chemins système. La valeur par défaut est la racine Drive. |
fileNamePrefix | Chaîne, facultative | Préfixe du nom de fichier. Peut contenir des lettres, des chiffres, -, _ (pas d'espaces). La valeur par défaut est la description. |
fileFormat | Chaîne, facultative | Format de sortie : "CSV" (par défaut), "GeoJSON", "KML", "KMZ", "SHP" ou "TFRecord". |
selectors | List<String>|String, facultatif | Liste des propriétés à inclure dans l'exportation : chaîne unique avec des noms séparés par une virgule ou liste de chaînes. |
maxVertices | Nombre, facultatif | Nombre maximal de sommets non coupés par géométrie. Les géométries comportant plus de sommets seront divisées en éléments plus petits que cette taille. |
priority | Nombre, facultatif | Priorité de la tâche dans le projet. Les tâches à priorité élevée sont planifiées plus tôt. Veuillez saisir un nombre entier compris entre 0 et 9 999. La valeur par défaut est 100. |
Exemples
Éditeur de code (JavaScript)
// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
Map.setCenter(-122.359, 37.428, 9);
Map.addLayer(img, {bands: ['B11', 'B8', 'B3'], min: 100, max: 3500}, 'img');
// Sample the image at 20 m scale, a point feature collection is returned.
var samp = img.sample({scale: 20, numPixels: 50, geometries: true});
Map.addLayer(samp, {color: 'white'}, 'samp');
print('Image sample feature collection', samp);
// Export the image sample feature collection to Drive as a CSV file.
Export.table.toDrive({
collection: samp,
description: 'image_sample_demo_csv',
folder: 'earth_engine_demos',
fileFormat: 'CSV'
});
// Export a subset of collection properties: three bands and the geometry
// as GeoJSON.
Export.table.toDrive({
collection: samp,
description: 'image_sample_demo_prop_subset',
folder: 'earth_engine_demos',
fileFormat: 'GeoJSON',
selectors: ['B8', 'B11', 'B12', '.geo']
});
// Export the image sample feature collection to Drive as a shapefile.
Export.table.toDrive({
collection: samp,
description: 'image_sample_demo_shp',
folder: 'earth_engine_demos',
fileFormat: 'SHP'
});
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap
pour le développement interactif.
import ee
import geemap.core as geemap
Colab (Python)
# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
m = geemap.Map()
m.set_center(-122.359, 37.428, 9)
m.add_layer(
img, {'bands': ['B11', 'B8', 'B3'], 'min': 100, 'max': 3500}, 'img'
)
# Sample the image at 20 m scale, a point feature collection is returned.
samp = img.sample(scale=20, numPixels=50, geometries=True)
m.add_layer(samp, {'color': 'white'}, 'samp')
display(m)
display('Image sample feature collection', samp)
# Export the image sample feature collection to Drive as a CSV file.
task = ee.batch.Export.table.toDrive(
collection=samp,
description='image_sample_demo_csv',
folder='earth_engine_demos',
fileFormat='CSV',
)
task.start()
# Export a subset of collection properties: three bands and the geometry
# as GeoJSON.
task = ee.batch.Export.table.toDrive(
collection=samp,
description='image_sample_demo_prop_subset',
folder='earth_engine_demos',
fileFormat='GeoJSON',
selectors=['B8', 'B11', 'B12', '.geo'],
)
task.start()
# Export the image sample feature collection to Drive as a shapefile.
task = ee.batch.Export.table.toDrive(
collection=samp,
description='image_sample_demo_shp',
folder='earth_engine_demos',
fileFormat='SHP',
)
task.start()
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/25 (UTC).
[null,null,["Dernière mise à jour le 2025/07/25 (UTC)."],[[["\u003cp\u003eCreates a batch task to export a FeatureCollection from Google Earth Engine to your Google Drive as a table in various formats (CSV, GeoJSON, KML, KMZ, SHP, or TFRecord).\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the export by specifying a description, output folder, filename prefix, file format, and properties to include.\u003c/p\u003e\n"],["\u003cp\u003eThe task can be started from the Tasks tab in Google Earth Engine and allows control over priority and geometry complexity.\u003c/p\u003e\n"],["\u003cp\u003eExporting allows you to download and utilize Earth Engine data outside the platform for further analysis and use.\u003c/p\u003e\n"]]],["This function exports a FeatureCollection as a table to Google Drive. Key actions include specifying the `collection`, task `description`, target `folder`, `fileNamePrefix`, and `fileFormat` (CSV, GeoJSON, KML, KMZ, SHP, or TFRecord). Optional actions include specifying `selectors` to limit exported properties, setting `maxVertices` to manage geometry size, and `priority` to control task scheduling. Multiple examples show how to export sampled image data to Drive in various formats.\n"],null,["# Export.table.toDrive\n\n\u003cbr /\u003e\n\nCreates a batch task to export a FeatureCollection as a table to Drive. Tasks can be started from the Tasks tab.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------|---------|\n| `Export.table.toDrive(collection, `*description* `, `*folder* `, `*fileNamePrefix* `, `*fileFormat* `, `*selectors* `, `*maxVertices* `, `*priority*`)` | |\n\n| Argument | Type | Details |\n|------------------|----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `collection` | FeatureCollection | The feature collection to export. |\n| `description` | String, optional | A human-readable name of the task. May contain letters, numbers, -, _ (no spaces). Defaults to \"myExportTableTask\". |\n| `folder` | String, optional | The Google Drive Folder that the export will reside in. Note: (a) if the folder name exists at any level, the output is written to it, (b) if duplicate folder names exist, output is written to the most recently modified folder, (c) if the folder name does not exist, a new folder will be created at the root, and (d) folder names with separators (e.g. 'path/to/file') are interpreted as literal strings, not system paths. Defaults to Drive root. |\n| `fileNamePrefix` | String, optional | The filename prefix. May contain letters, numbers, -, _ (no spaces). Defaults to the description. |\n| `fileFormat` | String, optional | The output format: \"CSV\" (default), \"GeoJSON\", \"KML\", \"KMZ\", or \"SHP\", or \"TFRecord\". |\n| `selectors` | List\\\u003cString\\\u003e\\|String, optional | A list of properties to include in the export; either a single string with comma-separated names or a list of strings. |\n| `maxVertices` | Number, optional | Max number of uncut vertices per geometry; geometries with more vertices will be cut into pieces smaller than this size. |\n| `priority` | Number, optional | The priority of the task within the project. Higher priority tasks are scheduled sooner. Must be an integer between 0 and 9999. Defaults to 100. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Sentinel-2 surface reflectance image.\nvar img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');\nMap.setCenter(-122.359, 37.428, 9);\nMap.addLayer(img, {bands: ['B11', 'B8', 'B3'], min: 100, max: 3500}, 'img');\n\n// Sample the image at 20 m scale, a point feature collection is returned.\nvar samp = img.sample({scale: 20, numPixels: 50, geometries: true});\nMap.addLayer(samp, {color: 'white'}, 'samp');\nprint('Image sample feature collection', samp);\n\n// Export the image sample feature collection to Drive as a CSV file.\nExport.table.toDrive({\n collection: samp,\n description: 'image_sample_demo_csv',\n folder: 'earth_engine_demos',\n fileFormat: 'CSV'\n});\n\n// Export a subset of collection properties: three bands and the geometry\n// as GeoJSON.\nExport.table.toDrive({\n collection: samp,\n description: 'image_sample_demo_prop_subset',\n folder: 'earth_engine_demos',\n fileFormat: 'GeoJSON',\n selectors: ['B8', 'B11', 'B12', '.geo']\n});\n\n// Export the image sample feature collection to Drive as a shapefile.\nExport.table.toDrive({\n collection: samp,\n description: 'image_sample_demo_shp',\n folder: 'earth_engine_demos',\n fileFormat: 'SHP'\n});\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A Sentinel-2 surface reflectance image.\nimg = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')\nm = geemap.Map()\nm.set_center(-122.359, 37.428, 9)\nm.add_layer(\n img, {'bands': ['B11', 'B8', 'B3'], 'min': 100, 'max': 3500}, 'img'\n)\n\n# Sample the image at 20 m scale, a point feature collection is returned.\nsamp = img.sample(scale=20, numPixels=50, geometries=True)\nm.add_layer(samp, {'color': 'white'}, 'samp')\ndisplay(m)\ndisplay('Image sample feature collection', samp)\n\n# Export the image sample feature collection to Drive as a CSV file.\ntask = ee.batch.Export.table.toDrive(\n collection=samp,\n description='image_sample_demo_csv',\n folder='earth_engine_demos',\n fileFormat='CSV',\n)\ntask.start()\n\n# Export a subset of collection properties: three bands and the geometry\n# as GeoJSON.\ntask = ee.batch.Export.table.toDrive(\n collection=samp,\n description='image_sample_demo_prop_subset',\n folder='earth_engine_demos',\n fileFormat='GeoJSON',\n selectors=['B8', 'B11', 'B12', '.geo'],\n)\ntask.start()\n\n# Export the image sample feature collection to Drive as a shapefile.\ntask = ee.batch.Export.table.toDrive(\n collection=samp,\n description='image_sample_demo_shp',\n folder='earth_engine_demos',\n fileFormat='SHP',\n)\ntask.start()\n```"]]