2016-09-06 107 views
0

我对整个世界,其细节是一个光栅文件:如何将一种光栅格式转换为另一种格式?

class  : RasterLayer 
dimensions : 18000, 43200, 777600000 (nrow, ncol, ncell) 
resolution : 0.008333333, 0.008333333 (x, y) 
extent  : -180, 180, -60, 90 (xmin, xmax, ymin, ymax) 
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source : E:\bc26pr50\bc26pr501.tif 
names  : bc26pr501 
values  : 0, 1100 (min, max) 

我想子集它模仿另一个光栅文件,该文件只适用于美国:

class  : RasterLayer 
dimensions : 3500, 7000, 24500000 (nrow, ncol, ncell) 
resolution : 0.01, 0.01 (x, y) 
extent  : -130, -60, 20, 55 (xmin, xmax, ymin, ymax) 
coord. ref. : NA 
data source : E:\dem.tif 
names  : dem 
values  : -85.25208, 4385.539 (min, max) 

我怎样才能变换分辨率以及数据集的子集?我必须为此使用RGDAL吗?任何指针都会有帮助。

回答

0

首先,使用作物()函数从光栅包:

r1.crop <- crop(r1,r2) # probably not obligatory, but will speed up the next action

然后使用二次采样函数

r1.resamp <- resample(r1.crop, r2) # can be slow

你应该非常接近你的目标。可能有更有效的方法,但先试一下然后优化。

1

我建议在包gdalUtils中使用gdalwarp函数。 您需要设置“te”和“tr”参数,也许需要点击“轻点”才能播放,但您应该轻松获得想要的内容。

HTH,

洛伦佐

相关问题