ee.data.getDownloadId
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
รับรหัสการดาวน์โหลด
แสดงผลรหัสและโทเค็นการดาวน์โหลด หรือค่า Null หากมีการระบุการเรียกกลับ
การใช้งาน | การคืนสินค้า |
---|
ee.data.getDownloadId(params, callback) | DownloadId |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
params | วัตถุ | ออบเจ็กต์ที่มีตัวเลือกการดาวน์โหลดพร้อมค่าที่เป็นไปได้ต่อไปนี้
name: ชื่อฐานที่จะใช้เมื่อสร้างชื่อไฟล์ มีผลเฉพาะเมื่อรูปแบบเป็น "ZIPPED_GEO_TIFF"
(ค่าเริ่มต้น), "ZIPPED_GEO_TIFF_PER_BAND" หรือ filePerBand เป็นจริง ค่าเริ่มต้นจะเป็นรหัสรูปภาพ (หรือ "ดาวน์โหลด" สำหรับรูปภาพที่คำนวณแล้ว) เมื่อรูปแบบเป็น "ZIPPED_GEO_TIFF", "ZIPPED_GEO_TIFF_PER_BAND" หรือ filePerBand เป็นจริง ไม่เช่นนั้นระบบจะสร้างสตริงอักขระแบบสุ่ม ระบบจะต่อท้ายชื่อวงดนตรีเมื่อ filePerBand เป็นจริง |
bands: คำอธิบายของแถบที่จะดาวน์โหลด ต้องเป็นอาร์เรย์ของชื่อแถบหรืออาร์เรย์ของพจนานุกรม โดยแต่ละรายการมีคีย์ต่อไปนี้ (พารามิเตอร์ที่ไม่บังคับจะใช้ได้ก็ต่อเมื่อ filePerBand เป็นจริงเท่านั้น)
id: ชื่อวงดนตรี ซึ่งเป็นสตริง (ต้องระบุ)
crs: สตริง CRS ที่ไม่บังคับซึ่งกำหนดการฉายแถบ
crs_transform: อาร์เรย์ตัวเลข 6 ตัวที่ไม่บังคับซึ่งระบุการแปลงแบบแอฟฟินจาก CRS ที่ระบุในลำดับแถวหลัก: [xScale, xShearing, xTranslation, yShearing, yScale, yTranslation]
dimensions: อาร์เรย์ของจำนวนเต็ม 2 จำนวนที่ไม่บังคับซึ่งกำหนดความกว้างและความสูงที่จะครอบตัดแถบ
scale: ตัวเลขที่ไม่บังคับซึ่งระบุสเกลในหน่วยเมตรของแถบ โดยระบบจะละเว้นหากมีการระบุ crs และ crs_transform |
crs: สตริง CRS เริ่มต้นที่จะใช้กับแถบความถี่ที่ไม่ได้ระบุไว้อย่างชัดเจน |
crs_transform: การแปลงแบบแอฟฟินเริ่มต้นที่จะใช้กับแถบใดก็ตามที่ไม่ได้ระบุแถบที่มีรูปแบบเดียวกันกับ
crs_transform ของแถบ |
dimensions: ขนาดการครอบตัดรูปภาพเริ่มต้นที่จะใช้กับแถบใดก็ตามที่ไม่ได้ระบุขนาด |
scale: สเกลเริ่มต้นที่จะใช้กับแถบความถี่ที่ไม่ได้ระบุไว้ โดยจะถูกละเว้นหากมีการระบุ crs และ
crs_transform |
region: รูปหลายเหลี่ยมที่ระบุภูมิภาคที่จะดาวน์โหลด ระบบจะไม่สนใจหากระบุ crs และ crs_transform |
filePerBand: จะสร้าง GeoTIFF แยกกันต่อแบนด์หรือไม่ (บูลีน) ค่าเริ่มต้นคือ True หากเป็นเท็จ ระบบจะสร้าง GeoTIFF รายการเดียวและจะไม่สนใจการแปลงระดับแถบทั้งหมด โปรดทราบว่าระบบจะไม่สนใจพารามิเตอร์นี้หากรูปแบบคือ "ZIPPED_GEO_TIFF" หรือ
"ZIPPED_GEO_TIFF_PER_BAND" |
format: รูปแบบการดาวน์โหลด ค่าใดค่าหนึ่งต่อไปนี้
- "ZIPPED_GEO_TIFF" (ไฟล์ GeoTIFF ที่อยู่ในไฟล์ ZIP, ค่าเริ่มต้น)
- "ZIPPED_GEO_TIFF_PER_BAND" (ไฟล์ GeoTIFF หลายไฟล์ที่รวมอยู่ในไฟล์ ZIP)
- "NPY" (รูปแบบไบนารีของ NumPy)
หากเป็น "GEO_TIFF" หรือ "NPY" ระบบจะไม่สนใจ filePerBand และการแปลงระดับแบนด์ทั้งหมด การโหลดเอาต์พุต NumPy จะส่งผลให้เกิดอาร์เรย์ที่มีโครงสร้าง |
id: เลิกใช้งานแล้ว โปรดใช้พารามิเตอร์รูปภาพ |
|
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 API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
"""Demonstrates the ee.data.getDownloadId method."""
import io
import requests
import ee
ee.Authenticate()
ee.Initialize()
# 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.
import numpy
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))
print(data)
print(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)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],["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"],null,[]]