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 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

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()