【发布时间】:2018-04-27 15:36:22
【问题描述】:
我正在 R 中进行土地利用/覆盖变化模拟。我有两张栅格地图,一张带有“土地使用/覆盖等级”,另一张带有“森林砍伐风险信息”。我正在使用风险栅格来识别更有可能被砍伐的森林像素(土地利用/覆盖类别之一)。到目前为止,我有一个可以工作的 R 代码,这是一个可以复制的示例:
#create land-use/cover raster
real <- raster(nrows=25, ncols=25, vals=round(rnorm(625, 3), 0))
real[ real > 3 ] <- 3 #just so we end with 3 land-use/cover classes
real[ real < 1 ] <- 1 #just so we end with 3 land-use/cover classes
plot(real)
#function to create the deforestation risk raster created by someone else
rtnorm <- function(n, mean = 0, sd = 1, min = 0, max = 1) {
bounds <- pnorm(c(min, max), mean, sd)
u <- runif(n, bounds[1], bounds[2])
qnorm(u, mean, sd)
}
risk <- raster(nrows=25, ncols=25, vals=rtnorm(n = 625, .1, .9)) #deforestation risk raster
plot(risk)
#The actual analysis starts here:
forest <- real #read the land-use/cover raster
forest[ forest != 3 ] <- NA #all left is class 3 (let's say, forest) in the raster
plot(forest, col="green")
deforestation <- sum(forest, risk) #identify the forest pixels with highest risk
plot(deforestation)
deforestation[ deforestation <= 3.5 ] <- 0 #rule to deforest the forest pixels
deforestation[ deforestation > 0 ] <- 100 #mark the pixels that will be deforested
plot(deforestation)
simulation <- sum(real, deforestation)
simulation[ simulation > 100 ] <- 2 #I use this to mark the forest pixels to a different land-use/cover class
plot(simulation)
我想更改用于选择将被砍伐的森林像素的规则(即 deforestation[ deforestation <= 3.5 ] <- 0 )。与其选择3.5 之类的阈值,我想知道是否可以设置要砍伐森林的特定数量的森林像素(例如 50),然后选择砍伐风险最高的 50 个森林像素。强>
我完全不知道如何在 R 中做这样的事情,所以任何建议都将受到高度赞赏。谢谢。
【问题讨论】: