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.


Try this:

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


  • How to add a text to a levelplot?
  • Exit URL on converted swf with swiffy
  • scanline: finding intersection points
  • how to subscript the x axis tick label
  • Add geom_rug like boxplots per group in ggplot2
  • Qt QGraphicsScene add and delete lines
  • Why do I get different results in plotting a NetCDF layer with “image(x,y,z)” and “plot (raster)” us
  • How to trim the values of x on X-axis in Chart control in Winforms?
  • Display a rectangle in ggplot with x axis in date format
  • How to do this program in C? Part 3.2-3.9 [closed]
  • Change coordinates to a series of rasters with multiple layers in R
  • ggplot legend showing transparency and fill color
  • Convert image in polar to cartesian coordinates
  • Mesh function seems to swap x and y values
  • How can I change QGraphicsView background using check box
  • get_pixel function raises bus error: 10
  • Get Room Price of Overlapping dates [closed]
  • Python 2.x or 3.x on a Chromebook
  • how to find function boundaries in binary code
  • custom_annotation with npc coordinates in ggplot2
  • Display Current Video in Windows Phone 8 using AudioVideoCaptureDevice?
  • plotting spatial points over a raster layer in r
  • Hatch area using pcolormesh in Basemap
  • Changing references to deprecated methods C++
  • jquery code not working without breakpoint
  • Motorola barcode scanner SDK events C#
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Row to Column conversion in Talend
  • Unable to get column index with table.getColumn method using custom table Model
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • Oledb connection string for excel files
  • Spark fat jar to run multiple versions on YARN
  • CSS Linear-gradient formatting issue accross different browsers
  • Master page gives error
  • Nant, Vault & Windows Integrated Authentication
  • Counter field in MS Access, how to generate?
  • Javascript + PHP Encryption with pidCrypt
  • Websockets service method fails during R startup
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?