This document describes the package “landscapeR”. This package is aimed at simulating categorical landscapes on actual geographical realms, starting from either empty landscapes or landscapes provided by the user (e.g. land use maps). The purpose is to provide a tool to tweak or create the landscape while retaining a high degree of control on its features, without the hassle of specifying each location attribute. In this it differs from other tools which generate null or neutral landscape in a theorethical space. Input and outputs are always raster datasets. Areas (and dimensions) of cells within a raster are always treated as equal, as the package is conceived to work on landscapes from fine to mid scale, where differences in cell areas due to latitude are relatively small. This may be an issue when working with non projected data at very wide scale (e.g. from subcontinental to global). All basic GIS operations are handled by the raster
package.
This package is aimed at simulating categorical landscapes on actual geographical realms, starting from either empty landscapes or landscapes provided by the user (e.g. land use maps). The purpose is to provide a tool to tweak or create the landscape while retaining a high degree of control on its features, without the hassle of specifying each location attribute. In this it differs from other tools which generate null or neutral landscape in a theorethical space.
Here it follows a set of examples, using landscapeR functions to generate various landscape configurations. Let’s start loading the required packages and making an empty landscape (by transforming a matrix into a geographical obkect):
library(landscapeR)
library(raster)
m <- matrix(0, 33, 33)
r <- raster(m, xmn=0, xmx=10, ymn=0, ymx=10)
makePatch
This is the basic function to create a single patch. For instance:
rr <- makePatch(r, size=500, rast=TRUE)
plot(rr)
Some more features can be specified about the patch. However, makeClass
should be preferred even when creating a single patch (see below).
makeClass
makeClass
generates a group of patches, as specified by its arguments. Example:
num <- 5
size <- 15
rr <- makeClass(r, num, size)
plot(rr)
Patches are allowed to be contiguous, so they may appear as a single patch in those instances:
num <- 75
size <- 10
rr <- makeClass(r, num, size)
plot(rr)
Each patch size and seed starting position can be specified as well:
num <- 5
size <- c(1,5,10,20,50)
pts <- c(1, 33, 1089, 1057, 545)
rr <- makeClass(r, num, size, pts)
plot(rr)
makeClass
should be used preferably when creating a single patch, as better error and exception handling is provided.
To create a single patch:
rr <- makeClass(r, 1, size=500, rast=TRUE)
plot(rr)
Some more features can be specified about the patch. For example, the following will create a patch with value 3, starting from the centre cell of the raster:
patchSize <- 500
newVal <- 3
centre <- 545
rr <- makeClass(r, 1, patchSize, centre, val=newVal, rast=TRUE)
plot(rr)
Forbidden cells can be specified by value, so the patch will occupy only the allowed background. The following will generate a new patch with value 5 and size 100 inside the patch created previously:
rr <- makeClass(rr, 1, 100, bgr=newVal, rast=TRUE, val=5)
plot(rr)
expandClass
Expand (and shrinks) classes starting from an existing landscape. Building on the previous:
rr <- makeClass(r, 1, patchSize, centre, val=newVal, rast=TRUE)
plot(rr)
rr <- expandClass(rr, 3, 250)
plot(rr)
This function can be used to mimic shapes, by providing a skeleton:
m[,17] <- 1
r <- raster(m, xmn=0, xmx=10, ymn=0, ymx=10)
plot(r)
rr <- expandClass(r, 1, 200)
plot(rr)
makeLine
Creates a linear feature, at a given convolution level and direction in degrees (zero is North)
m[] <- 0
r <- raster(m, xmn=0, xmx=10, ymn=0, ymx=10)
rr = makeLine(r, size=50, val=2, convol=0.05, spt=545, rast=TRUE)
plot(rr)