2016-09-06 108 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,

洛倫佐

相關問題