Learn R Programming

raster (version 1.6-10)

as.matrix: Get a matrix with raster cell values

Description

Return all values of a Raster* object as a matrix. For RasterLayer objects this is a wrapper around getValues(x, format='matrix' and rows and columns in the matrix represent rows and columns in the RasterLayer object. For other Raster* objects a warpper around getValues(x), and each column represents a layer. If there is insufficient memory to load all values, you can use getValues or getValuesBlock to read chunks of the file.

Usage

as.matrix(x, ...)

Arguments

x
Raster* object
...
Additional arguments. None implemented

Value

  • matrix

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
m <- as.matrix(r)
dim(m)
m[50:60, 25:35]

Run the code above in your browser using DataLab