Learn R Programming

NetLogoR (version 1.0.5)

world2spatRast: Convert a worldMatrix or worldArray object into a SpatRaster object

Description

Convert a worldMatrix object or a worldArray object into a SpatRaster object

Usage

world2spatRast(world)

# S4 method for worldMatrix world2spatRast(world)

# S4 method for worldArray world2spatRast(world)

Value

SpatRaster object. Patches value are retained from the world.

Arguments

world

WorldMatrix or worldArray object.

Author

Sarah Bauduin

Details

The SpatRaster returned has the same extent and resolution as the world with round coordinates at the center of the cells and coordinates x.5 at the edges of the cells.

Examples

Run this code
w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = runif(100))
r1 <- world2spatRast(w1)
terra::plot(r1)

w2 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 0)
w3 <- stackWorlds(w1, w2)
r3 <- world2spatRast(w3)
terra::plot(r3)

Run the code above in your browser using DataLab