to_raster: Convert objects to raster objects

Description Usage Arguments Value References See Also Examples

View source: R/spatial.R

Description

Convert objects to raster objects

Usage

1
2
3
4
5
to_raster(x, ...)

## S3 method for class 'msatsi_summary_ext'
to_raster(x, make.360 = TRUE,
  transpose = FALSE, no.zt = FALSE, ...)

Arguments

x

object

...

additional parameters to rasterFromXYZ

make.360

logical; should trends be in the range [0,360] rather than [-180,180]?

transpose

logical; should the x and y coordinates be swapped?

no.zt

logical; should the Z and T dimensions be excluded from the resulting object?

Value

A RasterBrick object

References

https://cran.r-project.org/web/packages/raster/vignettes/Raster.pdf

See Also

read.msatsi_summary_ext, brick

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require(raster)
require(viridis)

# dummy example
n <- 20
.x <- seq_len(n)
.sc <- 5
.asp <- 1/.sc
.y <- .sc*.x
xy <- expand.grid(x=.x, y=.y)
.t <- seq_len(nrow(xy))
z <- cos(.t*pi/90 + pi/6)**2
D <- data.frame(X=xy$x, Y=xy$y, Z=z, T=0, TR1=10, TR2=20, TR3=40)
class(D) <- c("msatsi_summary_ext", 'data.frame')

# Create the rasters (RasterBrick to be specific):
print(RB <- to_raster(D))

# extract certain layers
r.z <- raster::raster(RB, 'Z')
all.equal(r.z, raster::raster(RB, layer=1))

plot(r.z, col=viridis(n), zlim=c(0,1))

abarbour/stress documentation built on Oct. 5, 2019, 11:20 a.m.