Learn R Programming

ShapeSelectForest (version 1.7)

f2p.raster: Raster based flat-to-parameter function.

Description

Applies flat2parameter to each pixel in a raster to produce maps of disturbance parameters.

Usage

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

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.

layer.mag

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

Author

Liz Freeman

Details

The function writes a seven-layer raster with layers for disturbance agent, median disturbance year, median disturbance duration and magnitude of all image files given in INPUT.bands, in the order the filenames are listed in INPUT.bands.

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, layer.dur = 5, and layer.mag = 3.

If, for example, INPUT.bands = c(b5.fn, fi.fn, nbr.fn, and ndvi.fn), then the layers of the output file are:

1Disturbance Agent
2Disturbance Year
3Disturbance Duration
4Magnitude B5
5Magnitude FI
6Magnitude NBR
7Magnitude NDVI

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 f2p.raster
	ans <- f2p.raster(years = years, folder.in = folder.in, folder.out = folder.out, 
	OUTPUT.fn = "f2p_example.img", flat.pred.fn = flat.pred.fn, INPUT.bands = INPUT.bands)
}

Run the code above in your browser using DataLab