使用 terrain() 计算坡向,水不应该是 NA 或 0 吗?

问题描述 投票:0回答:1

我正在使用来自 USGS Earth Explorer 的 SRTM 数据(场景 ID:n03_e036_1arc_v3)。我使用 terra 包中的地形函数在 R 中绘制了海拔、坡度和坡向。前两个看起来很完美,但就方面而言,我更希望它计算西部大型水体的 NA,或某个任意数字,如 0。相反,它会产生奇怪的模式,如图所示:

areaDEM <- raster('DEM/dem.tif')
areaDEM <- projectRaster(areaDEM, crs = crs)
area_dem <- focal(areaDEM, w = matrix(1,15,15), fun = mean, NAonly = TRUE, na.rm = TRUE)

slope <- terrain(area_dem, opt = 'slope', unit = 'degrees')  # calculate slope
aspect <- terrain(area_dem, opt = 'aspect', unit = 'degrees') # calculate aspect

FIGURE 1: elevation, slope, and aspect (projection before)

我马上想到问题可能出在计算坡度和坡向之前进行投影步骤。这确实大大改变了输出,但是为湖计算的模式仍然非常奇怪:

areaDEM <- raster('DEM/dem.tif')
area_dem <- focal(areaDEM, w = matrix(1,15,15), fun = mean, NAonly = TRUE, na.rm = TRUE)

slope <- terrain(area_dem, opt = 'slope', unit = 'degrees')  # calculate slope
aspect <- terrain(area_dem, opt = 'aspect', unit = 'degrees') # calculate aspect

# join elevation, slope and aspect into a single object

dem <- stack(area_dem, slope, aspect)
names(dem) <- c('elevation', 'slope', 'aspect')
dem <- projectRaster(dem, crs = crs)

FIGURE 2: elevation, slope, and aspect (projection after)

r gis raster terra
1个回答
0
投票

猜猜我通过更改默认邻居解决了它。但我真的不明白为什么默认情况下它不起作用,所以如果有人愿意给我他们的两分钱,我将不胜感激。

aspect <- terra::terrain(area_dem, 'aspect', neighbors = 4, unit = "degrees")

现在我得到了一个漂亮的图,其中水的任意值(90 度)。根据文档,这是应该发生的事情。

As your can see here!

© www.soinside.com 2019 - 2024. All rights reserved.