Save multi layer RasterBrick to harddisk

I have a multilayer RasterBrick representing a topographic map that I want to save to the harddisk as grd or tif format, so that others can work with later.

This is the RasterBrick:

class : RasterBrick dimensions : 2400, 4200, 10080000, 3 (nrow, ncol, ncell, nlayers) resolution : 100, 100 (x, y) extent : 480000, 9e+05, 62000, 302000 (xmin, xmax, ymin, ymax) coord. ref. : NA data source : in memory names : layer.1, layer.2, layer.3 min values : 2.8725, 2.8725, 2.8725 max values : 254.5175, 254.5175, 254.5175

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/XEPCS.png" alt="enter image description here">

I tried to save it with this command:

outfile <- writeRaster(brick, filename='grid.tif', format="GTiff", overwrite=TRUE)

and this:

outfile <- writeRaster(m, filename='grid.grd', format="raster", overwrite=TRUE)

But the tif file is corrupt and the grd object only contains one layer and is not recognized as multi layer RasterBrick when I read it back in using raster().

The aim is to use the topographic map as background for thematic maps.

Answer1:

Try this:

outfile <- writeRaster(brick, filename='grid.tif', format="GTiff", overwrite=TRUE,options=c("INTERLEAVE=BAND","COMPRESS=LZW"))

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Save multi layer RasterBrick to harddisk