【问题标题】:How can I convert one raster format to another format?如何将一种光栅格式转换为另一种格式?
【发布时间】:2017-01-14 11:46:25
【问题描述】:

我有一个全世界的光栅文件,其详细信息是:

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 吗?任何指针都会有所帮助。

【问题讨论】:

    标签: r spatial gdal rgdal


    【解决方案1】:

    首先,使用 raster 包中的 crop() 函数:

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

    然后使用重采样功能

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

    你应该非常接近你的目标。可能有更有效的方法,但请先尝试此方法,然后再进行优化。

    【讨论】:

      【解决方案2】:

      我建议在包gdalUtils 中使用gdalwarp 函数。 您需要设置“te”和“tr”参数,并且可以使用“tap”玩一下,但您应该很容易得到您想要的。

      HTH,

      洛伦佐

      【讨论】:

        猜你喜欢
        • 2018-01-20
        • 1970-01-01
        • 1970-01-01
        • 2014-03-26
        • 1970-01-01
        • 1970-01-01
        • 2016-10-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多