公告:凡是在 
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
  
        
 
       
     
  
  
  
    
  
  
  
    
      ee.data.getDownloadId
    
    
      
    
    
      
      透過集合功能整理內容
    
    
      
      你可以依據偏好儲存及分類內容。
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
    
  
  
取得下載 ID。
傳回下載 ID 和權杖,如果指定回呼,則傳回 null。
| 用量 | 傳回 | 
|---|
ee.data.getDownloadId(params, callback) | DownloadId | 
| 引數 | 類型 | 詳細資料 | 
|---|
params | 物件 | 物件,內含下載選項,可能的值如下:
 name: 建構檔案名稱時使用的基本名稱。僅在格式為「ZIPPED_GEO_TIFF」(預設)、「ZIPPED_GEO_TIFF_PER_BAND」或 filePerBand 為 true 時適用。如果格式為「ZIPPED_GEO_TIFF」、「ZIPPED_GEO_TIFF_PER_BAND」或 filePerBand 為 true,則預設為圖片 ID (或計算圖片的「download」),否則會產生隨機字串。如果 filePerBand 為 true,系統會附加樂團名稱。 | 
 
 bands:  要下載的波段說明。必須是樂團名稱陣列或字典陣列,每個字典都包含下列鍵 (選用參數僅適用於 filePerBand 為 true 的情況):
 id:  樂團名稱 (字串,必填)。
 crs:  定義頻帶投影的選用 CRS 字串。 
 crs_transform:  6 個數字的選用陣列,以列優先順序指定來自指定 CRS 的仿射轉換:[xScale、xShearing、xTranslation、yShearing、yScale、yTranslation] 
 dimensions: :定義要裁剪樂團的寬度和高度 (兩個整數的選用陣列)。 
 scale:  (選用數字) 指定頻帶的比例 (以公尺為單位);如果指定 crs 和 crs_transform,系統會忽略這個值。  | 
 
 crs:  預設 CRS 字串,用於未明確指定 CRS 字串的任何波段。 | 
 
 crs_transform:  預設仿射轉換,用於未指定轉換的任何頻帶,格式與頻帶的 crs_transform 相同。 | 
 
 dimensions:  預設圖片裁剪尺寸,適用於未指定尺寸的任何樂團。 | 
 
 scale: :用於未指定任何頻帶的預設比例;如果指定 crs 和 crs_transform,則會忽略此值。 | 
 
 region: :指定要下載區域的多邊形;如果指定 crs 和 crs_transform,系統會忽略這個參數。 | 
 
 filePerBand:  是否要為每個波段產生個別的 GeoTIFF (布林值)。預設值為 true。如果設為 false,系統會產生單一 GeoTIFF,並忽略所有頻帶層級的轉換。請注意,如果格式為「ZIPPED_GEO_TIFF」或「ZIPPED_GEO_TIFF_PER_BAND」,系統會忽略這項設定。 | 
 
 format: 下載格式。下列其中一個欄位名稱:
-  「ZIPPED_GEO_TIFF」(以 ZIP 檔案包裝的 GeoTIFF 檔案,預設值)
 
-  「ZIPPED_GEO_TIFF_PER_BAND」(以 ZIP 檔案包裝的多個 GeoTIFF 檔案)
 
-  「NPY」(NumPy 二進位格式)
 
 如果是「GEO_TIFF」或「NPY」,系統會忽略 filePerBand 和所有頻帶層級的轉換。載入 NumPy 輸出內容會產生結構化陣列。 | 
 
 id:  已淘汰,請改用 image 參數。 | 
   | 
callback | 函式 (選用) | 選用回呼。如未提供,系統會同步發出呼叫。 | 
  
  
  範例
  
    
  
  
    
    
  
  
  
  
    
    
    
      程式碼編輯器 (JavaScript)
    
    
  // A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
// A small region within the image.
var region = ee.Geometry.BBox(-122.0859, 37.0436, -122.0626, 37.0586);
var downloadId = ee.data.getDownloadId({
    image: img,
    name: 'single_band',
    bands: ['B3', 'B8', 'B11'],
    region: region
});
print('Single-band GeoTIFF files wrapped in a zip file',
      ee.data.makeDownloadUrl(downloadId));
var downloadId = ee.data.getDownloadId({
  image: img,
  name: 'multi_band',
  bands: ['B3', 'B8', 'B11'],
  region: region,
  scale: 20,
  filePerBand: false
});
print('Multi-band GeoTIFF file wrapped in a zip file',
      ee.data.makeDownloadUrl(downloadId));
var downloadId = ee.data.getDownloadId({
  image: img,
  name: 'custom_single_band',
  bands: [
    {id: 'B3', scale: 10},
    {id: 'B8', scale: 10},
    {id: 'B11', scale: 20}
  ],
  region: region
});
print('Band-specific transformations',
      ee.data.makeDownloadUrl(downloadId));
var downloadId = ee.data.getDownloadId({
  image: img,
  bands: ['B3', 'B8', 'B11'],
  region: region,
  scale: 20,
  format: 'GEO_TIFF'
});
print('Multi-band GeoTIFF file',
      ee.data.makeDownloadUrl(downloadId));
  
    
  
  
    
  
  
  
  
    
  
    
  Python 設定
  請參閱 
    Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。
  import ee
import geemap.core as geemap
  
    
    
      Colab (Python)
    
    
  """Demonstrates the ee.data.getDownloadId method."""
import io
import numpy
import requests
# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
# A small region within the image.
region = ee.Geometry.BBox(-122.0859, 37.0436, -122.0626, 37.0586)
# Image chunk as a NumPy structured array.
download_id = ee.data.getDownloadId({
    'image': img,
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'format': 'NPY'
})
response = requests.get(ee.data.makeDownloadUrl(download_id))
data = numpy.load(io.BytesIO(response.content))
display(data)
display(data.dtype)
# Single-band GeoTIFF files wrapped in a zip file.
download_id = ee.data.getDownloadId({
    'image': img,
    'name': 'single_band',
    'bands': ['B3', 'B8', 'B11'],
    'region': region
})
response = requests.get(ee.data.makeDownloadUrl(download_id))
with open('single_band.zip', 'wb') as fd:
  fd.write(response.content)
# Multi-band GeoTIFF file wrapped in a zip file.
download_id = ee.data.getDownloadId({
    'image': img,
    'name': 'multi_band',
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'filePerBand': False
})
response = requests.get(ee.data.makeDownloadUrl(download_id))
with open('multi_band.zip', 'wb') as fd:
  fd.write(response.content)
# Band-specific transformations.
download_id = ee.data.getDownloadId({
    'image': img,
    'name': 'custom_single_band',
    'bands': [
        {'id': 'B3', 'scale': 10},
        {'id': 'B8', 'scale': 10},
        {'id': 'B11', 'scale': 20}
    ],
    'region': region
})
response = requests.get(ee.data.makeDownloadUrl(download_id))
with open('custom_single_band.zip', 'wb') as fd:
  fd.write(response.content)
# Multi-band GeoTIFF file.
download_id = ee.data.getDownloadId({
    'image': img,
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'format': 'GEO_TIFF'
})
response = requests.get(ee.data.makeDownloadUrl(download_id))
with open('multi_band.tif', 'wb') as fd:
  fd.write(response.content)
  
  
  
  
  
 
  
    
    
      
       
    
    
  
  
  除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
  上次更新時間:2025-10-30 (世界標準時間)。
  
  
  
    
      [null,null,["上次更新時間:2025-10-30 (世界標準時間)。"],[],["The `ee.data.getDownloadId` function generates a download ID and token for Earth Engine data. Key actions include specifying download parameters like image, bands, region, scale, and format in a `params` object. This can include band-specific transformations. The function returns a `DownloadId`, or null if a callback is specified, allowing for synchronous or asynchronous calls. The output can be configured to be a single or multiple GeoTIFF files wrapped in a zip or in NPY format.\n"]]