ee.Image.getDownloadURL

GeoTIFF または NumPy 形式の画像データの小さなチャンクのダウンロード URL を取得します。リクエストの最大サイズは 32 MB、グリッドの最大ディメンションは 10, 000 です。

RGB 可視化形式の PNG と JPG には getThumbURL を使用します。

ダウンロード URL を返します。コールバックが指定されている場合は undefined を返します。

用途戻り値
Image.getDownloadURL(params, callback)Object|String
引数タイプ詳細
これ: image画像Image インスタンス。
paramsオブジェクトダウンロード オプションを含むオブジェクト。次の値を使用できます。
name: ファイル名を構築するときに使用するベース名。形式が「ZIPPED_GEO_TIFF」(デフォルト)または filePerBand が true の場合にのみ適用されます。形式が「ZIPPED_GEO_TIFF」または 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 が生成され、すべてのバンドレベルの変換は無視されます。
format: ダウンロード形式。次のいずれか:
  • 「ZIPPED_GEO_TIFF」(GeoTIFF ファイルを ZIP ファイルでラップします。デフォルト)
  • 「GEO_TIFF」(GeoTIFF ファイル)
  • 「NPY」(NumPy バイナリ形式)
「GEO_TIFF」または「NPY」の場合、filePerBand とすべてのバンドレベルの変換は無視されます。NumPy 出力を読み込むと、構造化配列が生成されます。
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);

print('Single-band GeoTIFF files wrapped in a zip file',
  img.getDownloadURL({
    name: 'single_band',
    bands: ['B3', 'B8', 'B11'],
    region: region
  }));

print('Multi-band GeoTIFF file wrapped in a zip file',
  img.getDownloadURL({
    name: 'multi_band',
    bands: ['B3', 'B8', 'B11'],
    region: region,
    scale: 20,
    filePerBand: false
  }));

print('Band-specific transformations',
  img.getDownloadURL({
    name: 'custom_single_band',
    bands: [
      {id: 'B3', scale: 10},
      {id: 'B8', scale: 10},
      {id: 'B11', scale: 20}
    ],
    region: region
  }));

print('Multi-band GeoTIFF file',
  img.getDownloadURL({
    bands: ['B3', 'B8', 'B11'],
    region: region,
    scale: 20,
    format: 'GEO_TIFF'
  }));

Python の設定

Python API とインタラクティブな開発での geemap の使用については、 Python 環境のページをご覧ください。

import ee
import geemap.core as geemap

Colab(Python)

"""Demonstrates the ee.Image.getDownloadURL 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
url = img.getDownloadUrl({
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'format': 'NPY'
})
response = requests.get(url)
data = numpy.load(io.BytesIO(response.content))
print(data)
print(data.dtype)

# Single-band GeoTIFF files wrapped in a zip file.
url = img.getDownloadUrl({
    'name': 'single_band',
    'bands': ['B3', 'B8', 'B11'],
    'region': region
})
response = requests.get(url)
with open('single_band.zip', 'wb') as fd:
  fd.write(response.content)

# Multi-band GeoTIFF file wrapped in a zip file.
url = img.getDownloadUrl({
    'name': 'multi_band',
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'filePerBand': False
})
response = requests.get(url)
with open('multi_band.zip', 'wb') as fd:
  fd.write(response.content)

# Band-specific transformations.
url = img.getDownloadUrl({
    'name': 'custom_single_band',
    'bands': [
        {'id': 'B3', 'scale': 10},
        {'id': 'B8', 'scale': 10},
        {'id': 'B11', 'scale': 20}
    ],
    'region': region
})
response = requests.get(url)
with open('custom_single_band.zip', 'wb') as fd:
  fd.write(response.content)

# Multi-band GeoTIFF file.
url = img.getDownloadUrl({
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'format': 'GEO_TIFF'
})
response = requests.get(url)
with open('multi_band.tif', 'wb') as fd:
  fd.write(response.content)