makeLine | R Documentation |
Create a linear patch, setting direction and convolution. The higher the convolution degree, the weaker the linear shape (and direction).
makeLine(
context,
size,
direction = NULL,
convol = 0.5,
spt = NULL,
bgr = 0,
edge = FALSE,
rast = FALSE,
val = 1
)
context |
SpatRaster object or matrix, an empty landscape raster or a mask indicating where the patch cannot be generated (see bgr below). |
size |
integer. Size of the patch to be generated, as number of raster cells. |
direction |
numeric. The direction towards which the patch will point and grow, expressed in degrees between 0 and 360. |
convol |
numeric. Level of convolution to be assigned to the patch (default is |
spt |
integer or matrix. The seed point location around which the patch is generated (a random point is given by default). It can be an integer, as index of the cell in the raster, or a two columns matrix indicating x and y coordinates (an integer vector of length 2 is accepted too). |
bgr |
integer. A single value of background cells, where a patch can be generated (default is zero). Cells/classes which cannot be changed must have a different value. |
edge |
logical. Should the vector of edge cells of the patch be returned? |
rast |
logical. If TRUE returns a SpatRaster object, otherwise a vector of cell numbers where the patch occurs |
val |
integer. The value to be assigned to patch cells, when |
For any values of convol
> 0.8, no big differences are observed noted. Also direction is progressively lost
as convolution increases.
A vector of raster cell numbers, or a SpatRaster object if rast=TRUE
. If edge=TRUE
a
list of two vectors is returned: one for the inner raster cells and the second for cells at the edge of the patch.
library(terra)
r <- matrix(0,33,33)
r <- rast(r)
ext(r) = c(0, 10, 0, 10)
plot(makeLine(r, size=50, spt = 545, direction=45, convol=0.05, rast=TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.