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: : 指定された CRS からのアフィン変換を指定する 6 個の数値の配列(行優先順)。[xScale, xShearing, xTranslation, yShearing, yScale, yTranslation]
  • dimensions: : バンドが切り抜かれる幅と高さを定義する 2 つの整数の省略可能な配列。
  • scale: : バンドのスケールをメートル単位で指定する省略可能な数値。crs と crs_transform が指定されている場合は無視されます。
crs: 明示的に指定されていない帯域で使用するデフォルトの CRS 文字列。
crs_transform: : バンドの crs_transform と同じ形式で、アフィン変換を指定していないバンドに使用するデフォルトのアフィン変換。
dimensions: デフォルトの画像切り抜きサイズ。指定されていない帯域で使用されます。
scale: : スケールを指定しない帯域で使用するデフォルトのスケール。crscrs_transform が指定されている場合は無視されます。
ダウンロードする領域を指定するポリゴン。crscrs_transform が指定されている場合は無視されます。 region:
filePerBand: : バンドごとに個別の GeoTIFF を生成するかどうか(ブール値)。デフォルトは true です。false の場合、単一の 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)