classRaster_as.array: Export raster object to multidimensional array

as.arrayR Documentation

Export raster object to multidimensional array

Description

In the ursaRaster object the 3-dimensional image data are presented in 2-dimensional matrix. as.array transforms internal 2-dimensional data to the usual 3-dimansional data. as.matrix just extracts image data in internal 2-dimensional format.

Usage

## S3 method for class 'ursaRaster'
as.array(x, ...)

## non-public
.as.array(x, drop = FALSE, flip = FALSE, permute = FALSE, dim = FALSE)

Arguments

...

Arguments, which are passed to .as.array.

x

ursaRaster object

drop

Logical. If drop=TRUE then single-band images are presented without third dimension.

permute

Logical. If permute=FALSE then returned array has dimension (samples, lines, bands). If permute=TRUE then returned array has dimension (lines, samples, bands).

flip

Logical. If flip=TRUE then vertical flip (reverse coordinates for dimension #2) is applied for output image.

dim

Logical. If dim=TRUE then array's dimension is returned.

Details

Use permute=TRUE to create an object of class raster: as.raster(as.array(...))

The spatial reference system is lost.

Value

If dim=FALSE then as.array returns object of class array.
If dim=TRUE then as.array returns dimension of array.
as.matrix returns object of class matrix.

Author(s)

Nikita Platonov platonov@sevin.ru

See Also

as.raster is a function to direct export to the object of class raster.
as.matrix with argument/value coords=TRUE and as.data.frame for object of class ursaRaster keep spatial reference system.

Examples

session_grid(NULL)
a <- pixelsize()
a <- (a-global_min(a))/(global_max(a)-global_min(a))
b <- c(entire=a,half=a/2,double=a*2)
str(m <- as.matrix(b))
str(d1 <- as.array(b))
str(d2 <- as.array(b[1],drop=FALSE))
str(d3 <- as.array(b[1],drop=TRUE))
contour(d3)
filled.contour(d3)
d4 <- as.array(b,perm=TRUE)/global_max(b)
d4[is.na(d4)] <- 0
str(d4 <- as.raster(d4))
plot(d4)

ursa documentation built on Oct. 17, 2023, 5:11 p.m.