Export.table.toDrive

创建批量任务,以将 FeatureCollection 作为表格导出到云端硬盘。您可以在“任务”标签页中开始任务。

用法返回
Export.table.toDrive(collection, description, folder, fileNamePrefix, fileFormat, selectors, maxVertices, priority)
参数类型详细信息
collectionFeatureCollection要导出的要素集合。
description字符串,可选任务的简明易懂的名称。可以包含字母、数字、-、_(不能包含空格)。默认为“myExportTableTask”。
folder字符串,可选导出文件将位于的 Google 云端硬盘文件夹。注意:(a) 如果文件夹名称存在于任何级别,则输出会写入该文件夹;(b) 如果存在重复的文件夹名称,则输出会写入最近修改的文件夹;(c) 如果文件夹名称不存在,则会在根目录中创建一个新文件夹;(d) 带有分隔符(例如“path/to/file”)的文件夹名称会被解读为字面字符串,而不是系统路径。默认为云端硬盘根目录。
fileNamePrefix字符串,可选文件名前缀。可以包含字母、数字、-、_(不能包含空格)。默认为说明。
fileFormat字符串,可选输出格式:“CSV”(默认)、“GeoJSON”“KML”“KMZ”“SHP”或“TFRecord”。
selectorsList<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()