公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Terrain.products
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
根据地形 DEM 计算坡度、坡向和简单的山体阴影。
需要包含单个高程波段(以米为单位)的图片,或者如果包含多个波段,则需要包含一个名为“elevation”的波段。添加了以度为单位测量的名为“坡度”和“坡向”的输出波段,以及一个名为“山体阴影”的无符号字节输出波段,用于可视化。所有其他波段和元数据均从输入图像复制。局部梯度是使用每个像素的 4 个相邻像素计算的,因此图像边缘附近会出现缺失值。
用法 | 返回 |
---|
ee.Terrain.products(input) | 图片 |
参数 | 类型 | 详细信息 |
---|
input | 图片 | 高程图片,以米为单位。 |
示例
代码编辑器 (JavaScript)
// A digital elevation model.
var dem = ee.Image('NASA/NASADEM_HGT/001').select('elevation');
// Calculate slope. Units are degrees, range is [0,90).
var slope = ee.Terrain.slope(dem);
// Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.
var aspect = ee.Terrain.aspect(dem);
// Display slope and aspect layers on the map.
Map.setCenter(-123.457, 47.815, 11);
Map.addLayer(slope, {min: 0, max: 89.99}, 'Slope');
Map.addLayer(aspect, {min: 0, max: 359.99}, 'Aspect');
// Use the ee.Terrain.products function to calculate slope, aspect, and
// hillshade simultaneously. The output bands are appended to the input image.
// Hillshade is calculated based on illumination azimuth=270, elevation=45.
var terrain = ee.Terrain.products(dem);
print('ee.Terrain.products bands', terrain.bandNames());
Map.addLayer(terrain.select('hillshade'), {min: 0, max: 255}, 'Hillshade');
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# A digital elevation model.
dem = ee.Image('NASA/NASADEM_HGT/001').select('elevation')
# Calculate slope. Units are degrees, range is [0,90).
slope = ee.Terrain.slope(dem)
# Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.
aspect = ee.Terrain.aspect(dem)
# Display slope and aspect layers on the map.
m = geemap.Map()
m.set_center(-123.457, 47.815, 11)
m.add_layer(slope, {'min': 0, 'max': 89.99}, 'Slope')
m.add_layer(aspect, {'min': 0, 'max': 359.99}, 'Aspect')
# Use the ee.Terrain.products function to calculate slope, aspect, and
# hillshade simultaneously. The output bands are appended to the input image.
# Hillshade is calculated based on illumination azimuth=270, elevation=45.
terrain = ee.Terrain.products(dem)
display('ee.Terrain.products bands', terrain.bandNames())
m.add_layer(terrain.select('hillshade'), {'min': 0, 'max': 255}, 'Hillshade')
m
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eComputes terrain attributes like slope, aspect, and hillshade from a Digital Elevation Model (DEM).\u003c/p\u003e\n"],["\u003cp\u003eTakes an elevation image as input and adds output bands named 'slope', 'aspect', and 'hillshade'.\u003c/p\u003e\n"],["\u003cp\u003eSlope is measured in degrees (0-90), aspect in degrees (0=N, 90=E, 180=S, 270=W), and hillshade as an unsigned byte (0-255).\u003c/p\u003e\n"],["\u003cp\u003eOffers functions for individual attribute calculation (ee.Terrain.slope, ee.Terrain.aspect) and combined calculation (ee.Terrain.products).\u003c/p\u003e\n"],["\u003cp\u003eUses a 4-connected neighborhood for calculations, resulting in missing values at image edges.\u003c/p\u003e\n"]]],[],null,["# ee.Terrain.products\n\nCalculates slope, aspect, and a simple hillshade from a terrain DEM.\n\n\u003cbr /\u003e\n\nExpects an image containing either a single band of elevation, measured in meters, or if there's more than one band, one named 'elevation'. Adds output bands named 'slope' and 'aspect' measured in degrees plus an unsigned byte output band named 'hillshade' for visualization. All other bands and metadata are copied from the input image. The local gradient is computed using the 4-connected neighbors of each pixel, so missing values will occur around the edges of an image.\n\n| Usage | Returns |\n|------------------------------|---------|\n| `ee.Terrain.products(input)` | Image |\n\n| Argument | Type | Details |\n|----------|-------|--------------------------------|\n| `input` | Image | An elevation image, in meters. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A digital elevation model.\nvar dem = ee.Image('NASA/NASADEM_HGT/001').select('elevation');\n\n// Calculate slope. Units are degrees, range is [0,90).\nvar slope = ee.Terrain.slope(dem);\n\n// Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.\nvar aspect = ee.Terrain.aspect(dem);\n\n// Display slope and aspect layers on the map.\nMap.setCenter(-123.457, 47.815, 11);\nMap.addLayer(slope, {min: 0, max: 89.99}, 'Slope');\nMap.addLayer(aspect, {min: 0, max: 359.99}, 'Aspect');\n\n// Use the ee.Terrain.products function to calculate slope, aspect, and\n// hillshade simultaneously. The output bands are appended to the input image.\n// Hillshade is calculated based on illumination azimuth=270, elevation=45.\nvar terrain = ee.Terrain.products(dem);\nprint('ee.Terrain.products bands', terrain.bandNames());\nMap.addLayer(terrain.select('hillshade'), {min: 0, max: 255}, 'Hillshade');\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# A digital elevation model.\ndem = ee.Image('NASA/NASADEM_HGT/001').select('elevation')\n\n# Calculate slope. Units are degrees, range is [0,90).\nslope = ee.Terrain.slope(dem)\n\n# Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.\naspect = ee.Terrain.aspect(dem)\n\n# Display slope and aspect layers on the map.\nm = geemap.Map()\nm.set_center(-123.457, 47.815, 11)\nm.add_layer(slope, {'min': 0, 'max': 89.99}, 'Slope')\nm.add_layer(aspect, {'min': 0, 'max': 359.99}, 'Aspect')\n\n# Use the ee.Terrain.products function to calculate slope, aspect, and\n# hillshade simultaneously. The output bands are appended to the input image.\n# Hillshade is calculated based on illumination azimuth=270, elevation=45.\nterrain = ee.Terrain.products(dem)\ndisplay('ee.Terrain.products bands', terrain.bandNames())\nm.add_layer(terrain.select('hillshade'), {'min': 0, 'max': 255}, 'Hillshade')\nm\n```"]]