Save multi layer RasterBrick to harddisk

不羁的心 提交于 2019-12-23 15:03:00

问题


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 

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.


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/36936547/save-multi-layer-rasterbrick-to-harddisk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!