公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
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 環境頁面,瞭解 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()
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],["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"]]