R: Write RasterStack and preserve layer names

前端 未结 3 1418
你的背包
你的背包 2021-02-01 18:20

I have a raster stack, stk, consisting of three raster images in R. Here is a simple example

# set up a raster stack with three layers
> library(         


        
3条回答
  •  無奈伤痛
    2021-02-01 18:45

    You can make use of the native raster format:

    myRaster <- writeRaster(stk,"myStack.grd", format="raster")
    

    The raster grid format consists of the binary .gri file and the .grd header file. This will preserve your layernames. Note, however, that .gri binary files are not compressed.

    If you need to open raster grd files in other programs you will most likely need to write an additional header file. I usually use the ENVI header format to do that.

    hdr(myRaster, format = "ENVI")
    

    To open the file from qgis for example you'd select the .gri file (the binary) and it should work.

提交回复
热议问题