ee.Terrain.products

Tính toán độ dốc, hướng dốc và bóng đổ đơn giản từ DEM địa hình.

Mong đợi một hình ảnh chứa một dải độ cao duy nhất, được đo bằng mét, hoặc nếu có nhiều dải, thì một dải có tên là "độ cao". Thêm các dải đầu ra có tên "độ dốc" và "hướng dốc" được đo bằng độ, cùng với một dải đầu ra byte không dấu có tên "đổ bóng địa hình" để trực quan hoá. Tất cả các dải tần và siêu dữ liệu khác đều được sao chép từ hình ảnh đầu vào. Độ dốc cục bộ được tính bằng cách sử dụng 4 điểm ảnh lân cận được kết nối của mỗi điểm ảnh, vì vậy, các giá trị bị thiếu sẽ xuất hiện xung quanh các cạnh của hình ảnh.

Cách sử dụngGiá trị trả về
ee.Terrain.products(input)Hình ảnh
Đối sốLoạiThông tin chi tiết
inputHình ảnhHình ảnh độ cao, tính bằng mét.

Ví dụ

Trình soạn thảo mã (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');

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

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