Learn R Programming

NetLogoR (version 1.0.5)

raster2world: Convert a Raster* object into a worldMatrix or worldArray object

Description

Convert a RasterLayer object into a worldMatrix object or a RasterStack object into a worldArray object.

Usage

raster2world(raster)

# S4 method for ANY raster2world(raster)

Value

WorldMatrix or worldArray object depending on the input raster. Patches value are retained from the raster.

Arguments

raster

RasterLayer or RasterStack object.

Author

Sarah Bauduin

Details

See help("worldMatrix-class") or help("worldArray-class") for more details on the classes.

     The number of rows and columns, as well as the cell values of the `raster`
     are kept the same. However, to match the coordinates system and resolution of a
     `worldMatrix` or `worldArray`, the grid is shifted by a 1/2 cell to have
     round coordinate values at the center of the patches and patch size is equal to (1,1).
     The bottom left corner cell coordinates of the `worldMatrix` or `worldArray`
     will be (pxcor = 0, pycor = 0).

Examples

Run this code
if (requireNamespace("raster")) {
  r1 <- raster::raster(raster::extent(c(0, 10, 0, 10)), nrows = 10, ncols = 10)
  r1[] <- runif(100)
  w1 <- raster2world(r1)
  terra::plot(r1)
  terra::plot(w1)
}

Run the code above in your browser using DataLab