将多层 RasterBrick 保存到硬盘 [英] Save multi layer RasterBrick to harddisk

查看:45
本文介绍了将多层 RasterBrick 保存到硬盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表示地形图的多层 RasterBrick,我想将其以 grd 或 tif 格式保存到硬盘,以便其他人以后可以使用.

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.

这是 RasterBrick:

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)  

还有这个:

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

但是 tif 文件已损坏,并且 grd 对象仅包含一层,并且当我使用 raster() 读回它时未被识别为多层 RasterBrick.

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.

推荐答案

试试这个:

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

这篇关于将多层 RasterBrick 保存到硬盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆