公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.getDownloadURL
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
获取 GeoTIFF 或 NumPy 格式的小块图片数据的下载网址。请求大小上限为 32 MB,网格维度上限为 10000。
针对 RGB 可视化格式 PNG 和 JPG 使用 getThumb网址。
返回下载网址,如果指定了回调,则返回 undefined。
用法 | 返回 |
---|
Image.getDownloadURL(params, callback) | 对象|字符串 |
参数 | 类型 | 详细信息 |
---|
此: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: 一个可选的 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,并且所有波段级转换都会被忽略。 |
format: 下载格式。以下值之一:
- “ZIPPED_GEO_TIFF”(封装在 zip 文件中的 GeoTIFF 文件,默认)
- “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)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eImage.getDownloadURL\u003c/code\u003e provides a URL to download image data in GeoTIFF, NumPy, PNG or JPG formats.\u003c/p\u003e\n"],["\u003cp\u003eRequest size is limited to 32 MB and grid dimension to 10000.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003egetThumbURL\u003c/code\u003e for RGB visualizations in PNG and JPG formats.\u003c/p\u003e\n"],["\u003cp\u003eSpecify download parameters like bands, region, scale, and format within the \u003ccode\u003eparams\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a download URL or undefined if a callback is used.\u003c/p\u003e\n"]]],["`Image.getDownloadURL` retrieves download URLs for image data in GeoTIFF or NumPy formats, with a 32 MB maximum size and 10,000 grid dimension limit. Parameters include specifying `name`, `bands`, `crs`, `crs_transform`, `dimensions`, `scale`, `region`, and `filePerBand`, and `format`. Formats can be ZIPPED_GEO_TIFF, GEO_TIFF, or NPY. The `getThumbURL` method is recommended for RGB formats. The method returns a download URL or is undefined if a callback is provided.\n"],null,[]]