Learn R Programming

ShapeSelectForest (version 1.7)

f2a.raster: Raster based flat-to-annual function.

Description

Applies flat2annual to each pixel in a raster to produce time series maps of disturbance.

Usage

f2a.raster(years, folder.in, folder.out, OUTPUT.fn, flat.pred.fn, INPUT.bands,
layer.shape = 1, layer.dyr = 2, layer.dur = 5)

Value

The function does not return a value. Instead, a multi-band .img map file is created.

Arguments

years

Vector of the years included in the time series data.

folder.in

Folder (full path) containing the input rasters.

folder.out

Folder where the output will be written.

OUTPUT.fn

Filename for output. The extension of this filename will specify the output file type. For image files, OUTPUT.fn should end in .img.

flat.pred.fn

Filename of a single layer .img file of the disturbance agents. The agents are specified by the integers from 0 to 6.

0Unclassified
1Conversion
2Fire
3Harvest
4Stable
5Stress
6Recovery

INPUT.bands

Filenames of the multi-layer .img files of the shapes to be used.

layer.shape

Number giving the layer of the shape files containing the shape data.

layer.dyr

Number giving the layer of the shape files containing the disturbance year data.

layer.dur

Number giving the layer of the shape files containing the disturbance duration data.

Author

Liz Freeman

Details

The function writes a multi-layer raster with one layer for each year in years given the predicted agent for each pixel at each year.

The layers for shape, dyr and dur need to be the same in all files named in INPUT.bands. The default is layer.shape = 1, layer.dyr = 2, and layer.dur = 5.

See Also

flat2annual

Examples

Run this code
if (FALSE) {
	# define years
	years <- c(1984, 1986:2010)

	# define a folder for all output
	folder.in <- paste(system.file(package = "ShapeSelectForest"), 
	"extdata", "helpexamples", sep = "/")
	folder.out <- getwd()	

	# define filenames
	flat.pred.fn <- "MINI_FLATPRED.img"
	b5.fn <- "MINI_B5.img"
	fi.fn <- "MINI_FI.img"
	nbr.fn <- "MINI_NBR.img"
	ndvi.fn <- "MINI_NDVI.img"
	INPUT.bands <- c(b5.fn, fi.fn, nbr.fn, ndvi.fn)

	# call f2a.raster
	ans <- f2a.raster(years = years, folder.in = folder.in, folder.out = folder.out, 
	OUTPUT.fn = "f2a_example.img", flat.pred.fn = flat.pred.fn, INPUT.bands = INPUT.bands)
}

Run the code above in your browser using DataLab