公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
图片缩减
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需缩减 Image
,请使用 image.reduce()
。对图片进行缩减的运作方式与 imageCollection.reduce()
类似,只不过是将图片的波段输入到缩减器,而不是集合中的图片。输出也是一张图片,其波段数等于 reducer 输出数。例如:
Code Editor (JavaScript)
// Load an image and select some bands of interest.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')
.select(['B4', 'B3', 'B2']);
// Reduce the image to get a one-band maximum value image.
var maxValue = image.reduce(ee.Reducer.max());
// Display the result.
Map.centerObject(image, 10);
Map.addLayer(maxValue, {max: 13000}, 'Maximum value image');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Load an image and select some bands of interest.
image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select(
['B4', 'B3', 'B2']
)
# Reduce the image to get a one-band maximum value image.
max_value = image.reduce(ee.Reducer.max())
# Display the result.
m = geemap.Map()
m.center_object(image, 10)
m.add_layer(max_value, {'max': 13000}, 'Maximum value image')
m
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eimage.reduce()\u003c/code\u003e processes an image's bands with a reducer, similar to how \u003ccode\u003eimageCollection.reduce()\u003c/code\u003e processes images in a collection.\u003c/p\u003e\n"],["\u003cp\u003eIt outputs a new image with band count equal to the reducer's output count, for instance, using \u003ccode\u003eee.Reducer.max()\u003c/code\u003e results in a single-band image with the maximum value across the input bands.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code demonstrates reducing a Landsat 8 image to a single-band image representing the maximum value across selected bands (B4, B3, B2).\u003c/p\u003e\n"]]],[],null,["# Image Reductions\n\nTo reduce an `Image`, use `image.reduce()`. Reducing an image\nfunctions in an analogous way to `imageCollection.reduce()`, except the\nbands of the image are input to the reducer rather than the images in the collection. The\noutput is also an image with number of bands equal to number of reducer outputs. For\nexample:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load an image and select some bands of interest.\nvar image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')\n .select(['B4', 'B3', 'B2']);\n\n// Reduce the image to get a one-band maximum value image.\nvar maxValue = image.reduce(ee.Reducer.max());\n\n// Display the result.\nMap.centerObject(image, 10);\nMap.addLayer(maxValue, {max: 13000}, 'Maximum value image');\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Load an image and select some bands of interest.\nimage = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select(\n ['B4', 'B3', 'B2']\n)\n\n# Reduce the image to get a one-band maximum value image.\nmax_value = image.reduce(ee.Reducer.max())\n\n# Display the result.\nm = geemap.Map()\nm.center_object(image, 10)\nm.add_layer(max_value, {'max': 13000}, 'Maximum value image')\nm\n```"]]