Learn R Programming

inlmisc (version 0.5.5)

ExportRasterStack: Export a Raster Stack

Description

Write a raster-stack, a collection of raster layers, to local directories using multiple file formats.

Usage

ExportRasterStack(rs, path, zip = "", col = NULL)

Arguments

rs

'RasterStack' or 'RasterBrick'. Collection of '>RasterLayer objects with the same extent and resolution.

path

'character' string. Path name to write raster stack.

zip

'character' string. If there is no zip program on your path (on windows), you can supply the full path to a zip.exe here, in order to make a KMZ file.

col

'character' vector. Color names

Value

Invisible NULL

Details

Five local directories are created under path and named after their intended file formats: Comma-Separated Values (csv), Portable Network Graphics (png), Georeferenced TIFF (tif), R Data (rda), and Keyhole Markup Language (kml). For its reference system, kml uses geographic coordinates: longitude and latitude components as defined by the World Geodetic System of 1984. Therefore, the conversion of gridded data between cartographic projections may introduce a new source of error.

Examples

Run this code
# NOT RUN {
rs <- raster::stack(system.file("external/rlogo.grd",
                                package = "raster"))
print(rs)
path <- file.path(getwd(), "rlogo")
dir.create(path)
ExportRasterStack(rs, path)
list.files(normalizePath(path, winslash = "/"),
           full.name = TRUE, recursive = TRUE,
           include.dirs = TRUE)

unlink(path, recursive = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab