【发布时间】:2019-04-03 10:33:51
【问题描述】:
当我尝试运行波段数学时,结果始终是一种颜色的图像,并且最小值和最大值与预测的值非常不同。 我在这里没有找到任何显示此问题的问题。 我是这样设计的
r.stack <- stack("path to raster file"))
我使用重采样而不是裁剪来去除原始图像中的白色边缘
prj <- "+proj=utm +zone=23 +south +datum=WGS84 +units=m"
r <- raster(res=11.47, ext=extent(c(301496, 323919, 9888968, 9913982)), crs=prj, vals=NA
r.stack <- resample(r.stack, r)
之后图像具有以下配置:
> class : RasterBrick
> dimensions : 2181, 1955, 4263855, 4 (nrow, ncol, ncell, nlayers)
> resolution : 11.47, 11.47 (x, y)
> extent : 301496, 323919.8, 9888966, 9913982 (xmin, xmax, ymin, ymax)
>coord. ref. : +proj=utm +zone=23 +south +datum=WGS84 +units=m +ellps=WGS84 +towgs84=0,0,0
>data source : in memory
>names : l.1, l.2, l.3, l.4
>min values : -36.12217, -45.12768, -46.30455, -35.26328
>max values : 10.567671, 4.050200, 3.878345, 11.613799
然后使用下面的函数进行计算
f <- function(x){
(x[[2]])/(x[[1]])
}
s <- r.stack[[c(1,2)]]
r2 <- calc(s, f)
而且我也很有趣地运行了叠加层
f <- function(x,y){
y/x
}
r2 <- overlay(r.stack[[1]], r.stack[[2]], fun= f)
任何方法都会导致image of one value
我是否遗漏了一些步骤?
【问题讨论】:
-
I use resampling instead of crop to cut out the white edges。这通常是一个坏主意,因为它会降低您的数据质量。使用crop或trim。