Description Usage Arguments Details Value Author(s)
Fire function for block burning
1 2 | fireBlockBurnGRASS(input, output, pathToGrassDB, year,
doesBlockBurnFunction, overwrite = FALSE)
|
input |
name of the vector layer containing the polygons outlining the blocks |
output |
name of the output raster layer indicating cells which burned (==1) and which did not burn (==NULL) |
pathToGrassDB |
path to the sqlite grass db containing the attribute table of the layer |
year |
year of evaluation |
doesBlockBurnFunction |
R function determining if a certain block burns, taking the "fires" table in the as input |
overwrite |
if TRUE, the |
This function simulates block burning, i.e. the burning
of whole blocks. The blocks are defined by the polygons
in the vector input
layer and this function simly
identifies blocks which are burning and adjusts the
attributes table of input
(see below for details)
accordingly and returns a output
raster layer
containing 1
for cell burned and NULL
for
not burned.
The adjustments of the attributre table of the vector
layer input
are as follow:
burns
: This logical
column is
added if it does not exist yet or owerwritten. It
contains logical
values indicating if the
corresponding block burns. The values will be overwritten
each time the function is called.
burns.YEAR
: This logical
column will be added if it does not exist or overwritten.
YEAR is replaced by the argument year
. The values
are identical to the column burns
but will not be
overwritten if the function is called with a different
year
argument. Will be overwritten if the function
is called with the same year
argument.
countFires
: This integer
column is added if it does not exist or it will be
updated. It contains integer
values indicating the
number of times this block has burned. It will be updated
each time the function is called.
lastFire
: This integer
column
is added if it does not exist or it will be updated. It
contains the year
when the last time the block has
burned. If it has not burned yet, the value is NA
.
It will be updated each time the function is run.
To determine if a block burns, an R function is passed
as the argument doesBlockBurnFunction
. This
function has to have the following form:
doesBlockBurnFunction <- function(fires){...}
where
fires
is a data.frame
containing the attribute table of
the input
layer. This fires
data.frame
has the columns as mentioned above,
although they might not contain any values if the
function firesBlockBurn
has not been called yet.
The function has to return a logical
vector of the
same length as the number of rows in the fires
dataframe.
An example would be:
doesBlockBurn = function(fires) {
return(as.logical(rbinom(n=nrow(fires), size=1, 0.5)))
}
This function does not respects MASK in GRASS.
invisible returns the updated attribute table of
input
as data.frame
Rainer M Krug <Rainer@krugs.de>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.