Export.table.toDrive Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
Export.table.toDrivefunction creates a batch task to export a FeatureCollection as a table to Google Drive.This function requires a
collectionargument (the FeatureCollection to export) and has several optional arguments likedescription,folder,fileNamePrefix,fileFormat,selectors,maxVertices, andpriority.The exported table can be in various file formats including "CSV" (default), "GeoJSON", "KML", "KMZ", "SHP", or "TFRecord".
Examples demonstrate how to export a FeatureCollection to Drive using both JavaScript in the Code Editor and Python in Colab.
| Usage | Returns |
|---|---|
Export.table.toDrive(collection,description,folder,fileNamePrefix,fileFormat,selectors,maxVertices,priority) |
| Argument | Type | Details |
|---|---|---|
collection | FeatureCollection | The feature collection to export. |
description | String, optional | A human-readable name of the task. May contain letters, numbers, -, _ (no spaces). Defaults to "myExportTableTask". |
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. |
fileNamePrefix | String, optional | The filename prefix. May contain letters, numbers, -, _ (no spaces). Defaults to the description. |
fileFormat | String, optional | The output format: "CSV" (default), "GeoJSON", "KML", "KMZ", or "SHP", or "TFRecord". |
selectors | List<String>|String, optional | A list of properties to include in the export; either a single string with comma-separated names or a list of strings. |
maxVertices | Number, optional | Max number of uncut vertices per geometry; geometries with more vertices will be cut into pieces smaller than this size. |
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. |
Examples
Code Editor (JavaScript)
// A Sentinel-2 surface reflectance image.varimg=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.varsamp=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'});
Python setup
See the Python Environment page for information on the Python API and usinggeemap for interactive development.
importeeimportgeemap.coreasgeemap
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()
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-08 UTC.