Description Usage Arguments Author(s) Examples
View source: R/raster2matrix.r
raster2matrix
converts a raster layer to a matrix or array. Used by readbin and writebin.
1 2 3 | raster2matrix(RasterLayer)
raster2array(RasterLayer)
|
RasterLayer |
raster layer to be converted. |
Robert K. Bauer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library('raster')
owd <- getwd()
setwd(system.file("test_files", package="oceanmap"))
check_gzfiles() # return file summary-table
gz.files <- Sys.glob('*.gz') # load sample-'.gz'-files
raster.file <- readbin(gz.files[1]) # loading gz-file as raster-layer
image(raster.file)
## Example 1: converting single raster layer to matrix
image(as.matrix(raster.file)) # unflipped conversion
m <- raster2matrix(raster.file) # converting raster-layer to matrix
image(m)
## Example 2: converting double raster layer to an array
stack.file <- stack(raster.file,raster.file)
image(as.array(stack.file)[,,1]) # unflipped conversion
a <- raster2array(stack.file) # converting raster-layer to array (works also with raster2matrix)
image(a[,,1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.