公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
Export.table.toDrive
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建批量任务,以将 FeatureCollection 作为表格导出到云端硬盘。您可以在“任务”标签页中开始任务。
用法 | 返回 |
---|
Export.table.toDrive(collection, description, folder, fileNamePrefix, fileFormat, selectors, maxVertices, priority) | |
参数 | 类型 | 详细信息 |
---|
collection | FeatureCollection | 要导出的要素集合。 |
description | 字符串,可选 | 任务的简明易懂的名称。可以包含字母、数字、-、_(不能包含空格)。默认为“myExportTableTask”。 |
folder | 字符串,可选 | 导出文件将位于的 Google 云端硬盘文件夹。注意:(a) 如果文件夹名称存在于任何级别,则输出会写入该文件夹;(b) 如果存在重复的文件夹名称,则输出会写入最近修改的文件夹;(c) 如果文件夹名称不存在,则会在根目录中创建一个新文件夹;(d) 带有分隔符(例如“path/to/file”)的文件夹名称会被解读为字面字符串,而不是系统路径。默认为云端硬盘根目录。 |
fileNamePrefix | 字符串,可选 | 文件名前缀。可以包含字母、数字、-、_(不能包含空格)。默认为说明。 |
fileFormat | 字符串,可选 | 输出格式:“CSV”(默认)、“GeoJSON”“KML”“KMZ”“SHP”或“TFRecord”。 |
selectors | List<String>|String,可选 | 要包含在导出中的属性列表;可以是包含以英文逗号分隔的名称的单个字符串,也可以是字符串列表。 |
maxVertices | 数字,可选 | 每个几何图形的未切割顶点数量上限;顶点数量超过此上限的几何图形将被切割成小于此大小的块。 |
priority | 数字,可选 | 任务在项目中的优先级。优先级较高的任务会更早安排。必须是介于 0 到 9999 之间的整数。默认值为 100。 |
示例
代码编辑器 (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'
});
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
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()
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\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```"]]