如何重新采样栅格捕捉到现有网格?

Wra*_*raf 5 aggregate r raster resampling snapping

我想在定义的网格单元格中将栅格从高分辨率重新采样到低分辨率(具有不同的范围).有没有办法使用现有的栅格文件作为捕捉的输入?

在光栅包,aggregate并且resample似乎是足够的,但我无法找到如何做到这一点.

Sim*_*lon 7

projectRaster如果您在一个投影和分辨率中有一个光栅,并且需要以不同的特定分辨率和投影输出,则可以使用此功能.

from参数是您高分辨率光栅和to参数是你的低分辨率的光栅.确保选择正确的聚合方法(即bilinear连续数据和ngb(最近邻居)分类数据).

require( raster )

#  Projection info
proj1 <- CRS("+proj=laea +lon_0=20 +lat_0=5 +ellps=sphere +unit=km +to_meter=1e3")
proj2 <-  CRS("+proj=longlat +datum=WGS84 +ellps=WGS84")
#  High res raster
r1km <- raster( nrows = 1515 , ncols = 2300 , xmn = -4000 , xmx = -1700 , ymn = -15 , ymx = 1500 , crs = proj1 )

#  Low res raster
r5km <- raster( nrows = 303 , ncols = 460 , xmn = -20 , xmx = -5 , ymn = 4 , ymx = 15 , crs = proj2 )

#  Set some values in high res raster
pts <- rasterToPoints(r1km)
values( r1km ) <-  0.01*pts[,1] + sin(0.02*pi*pts[,2])

#  Reproject using the attributes of the low res raster for output
out <- projectRaster( from = r1km , to = r5km , method = "bilinear" )

#  Plot - extent of second raster doesn't fully cover first so some data is missing
par( mfrow = c(1,2) )
plot( r1km )
plot( out )
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

如果您的输入和输出数据相同,除了分辨率,您可以使用聚合...

#  If same extent and resolution require use aggregate
r1 <- raster(system.file("external/rlogo.grd", package="raster"))
r5 <- aggregate( r1 , fact = 5 , method = "bilinear" )
par( mfrow = c(1,2) )
plot( r1 )
plot( r5 )
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


WAF*_*WAF 1

您可以使用 启动外部命令并system调用gdal_translateorgdal_warp命令。这当然需要安装 gdal 实用程序