【发布时间】:2021-10-11 20:16:22
【问题描述】:
我有一个 50 米分辨率的光栅。我正在努力使它达到 30 米。 我尝试了 raster::disaggregate 函数,但分辨率没有变为 30 米。
library(raster)
a = raster("file.tif")
b = disaggregate(a, fact=30/50, method='bilinear')
如果您有一些替代解决方案,那将非常有帮助。提前致谢。
【问题讨论】:
我有一个 50 米分辨率的光栅。我正在努力使它达到 30 米。 我尝试了 raster::disaggregate 函数,但分辨率没有变为 30 米。
library(raster)
a = raster("file.tif")
b = disaggregate(a, fact=30/50, method='bilinear')
如果您有一些替代解决方案,那将非常有帮助。提前致谢。
【问题讨论】:
disaggregate 函数需要一个整数作为 fact 参数。您可以改用resample 函数。我正在使用一些示例数据,因为我没有您的数据,因此您需要针对您的环境进行修改。我将 40 x 40 重新采样到 5 x 5 以使图显示出差异。
library(raster)
rr <- raster(system.file("external/test.grd", package="raster"))
res(rr) # 40 by 40
#[1] 40 40
# Create a raster to aim for - make sure its projection is the same as the original and
# uses metres.
proj4string(rr)
#[1] "+proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +datum=WGS84 +units=m +no_defs"
ss <- raster(resolution=c(5,5), crs=proj4string(rr), ext=extent(rr))
res(ss) # 5 by 5
#[1] 5 5
rs <- resample(rr, ss) # This makes a new raster with the 5 by 5 resolution
res(rs) # should be 5 by 5
#[1] 5 5
【讨论】: