【发布时间】:2019-06-21 05:42:41
【问题描述】:
我有两个大小相同的栅格,包含来自同一位置的数据,但数据类型不同(一个栅格具有坡度数据,另一个栅格具有坡向数据)。我希望能够一次查看一个方面的坡度数据,因此我试图创建一个设置(可能是 if/else 语句?),其中我说“如果(方面条件)在一个栅格中得到满足,则坡度数据将从另一个栅格中的同一像素中提取。
#I have a slope and an aspect raster that i pulled
library(raster)
library(rgdal)
library(sp)
aspect <- raster("geotiff name here")
slope <- raster("geotiff name here")
#Looking at the north aspect (between 0-22.5 degrees or 337.5-360 degrees)
#First I am setting the pixels in the aspect raster that correspond to north
#equal to 1, and the values that don't = 0
aspect[aspect >= 0 & aspect <= 22.5] <- 1
aspect[aspect >= 337.5 & aspect <= 360] <- 1
aspect[aspect > 22.5 & aspect < 337.5] <- 0
#Here i am saving the indices of the raster that face north to a new one
north <- which(aspect == 1, cells = true)
然后我只想从坡面栅格的像素中读取数据,这些像素从纵横比栅格中分配了一个 TRUE 值,但这是我被难住的地方!我最近开始使用 R,所以可能有一种简单的方法可以做到这一点,我很想念任何帮助。非常感谢!
【问题讨论】:
-
完成!对此感到抱歉