Learn R Programming

gdtools (version 0.4.0)

raster_write: Draw/preview a raster to a png file

Description

Draw/preview a raster to a png file

Usage

raster_write(x, path, width = 480, height = 480, interpolate = FALSE)

Arguments

x

A raster object

path

name of the file to create

width, height

Width and height in pixels.

interpolate

A logical value indicating whether to linearly interpolate the image.

Examples

Run this code
r <- as.raster(matrix(hcl(0, 80, seq(50, 80, 10)),
 nrow = 4, ncol = 5))
filepng <- tempfile(fileext = ".png")
raster_write(x = r, path = filepng, width = 50, height = 50)

Run the code above in your browser using DataLab