Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A landscape simulator for R

NotificationsYou must be signed in to change notification settings

dariomasante/landscapeR

Repository files navigation

A landscape simulator for R.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. All basic GIS operations are handled by theraster package.

URL:https://cran.r-project.org/package=landscapeR
Reference manual:landscapeR.pdf

Citation: Thomas, A., Masante, D., Jackson, B., Cosby, B., Emmett, B., Jones, L. (2020). Fragmentation and thresholds in hydrological flow-based ecosystem services. Ecological Applications.https://doi.org/10.1002/eap.2046

To install, open a R session and select 'landscapeR' from the packages list, or type in the console:

install.packages("landscapeR")

Alternatively to install from source:

  • download thesource file (.tar.gz) to the R working directory (or any other directory)
  • start an R session
  • run the following commands in the console:
## Install the required packagesinstall.packages("raster",dependencies=T,clean=T)## Install landscapeR (full path to the file, if not in the R working directory)install.packages("~/landscapeR_1.3.tar.gz",repos=NULL,type="source")

Here it follows a set of examples, using landscapeR functions to generate various landscape configurations.Similar examples are showed in thevignette.Let's start loading the required packages and making an empty landscape (by transforming a matrix into a geographical obkect):

library(landscapeR)## Create an empty landscapelibrary(terra)m = matrix(0, 33, 33)r = rast(m)ext(r) = c(0, 10, 0, 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. For example, the following will create a patch with value 3, starting from the centre cell of the raster:

patchSize = 500newVal = 3centre = 545rr = makePatch(r, 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 existing patch:

rr = makePatch(rr, 100, bgr=newVal, rast=TRUE, val=5)plot(rr)

makeClass

makeClass generates a group of patches, as specified by its arguments. Example:

num = 5size = 15rr = makeClass(r, num, size)plot(rr)

Patches are allowed to be contiguous, so they may appear as a single patch in those instances:

num = 75size = 10rr = makeClass(r, num, size)plot(rr)

Each patch size and seed starting position can be specified as well:

num = 5size = c(1,5,10,20,50)pts = c(1, 33, 1089, 1057, 545)rr = makeClass(r, num, size, pts)plot(rr)

expandClass

Expand (and shrinks) classes starting from an existing landscape. Building on the previous:

rr = expandClass(rr, 1, 250)plot(rr)

This function can be used to mimic shapes, by providing a skeleton:

m[,17] = 1r = rast(m)ext(r) = c(0, 10, 0, 10)par(mfrow=c(1,2))plot(r)rr = expandClass(r, 1, 200)plot(rr)

makeLine

Create a linear patch, setting direction and convolution. The higher the convolution degree, the weaker thelinear shape (and direction).

par(mfrow=c(1,2))rr = makeLine(r, size=50, direction=90, rast=TRUE, spt=545, convol=0.25)plot(rr)plot(makeLine(r, size=50, direction=90, rast=TRUE, spt=545, convol=0.6))

About

A landscape simulator for R

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp