predict.ptf.raster: Run pedotransfer functions on a stack of raster layers

View source: R/predict_ptf_raster.R

predict.ptf.rasterR Documentation

Run pedotransfer functions on a stack of raster layers

Description

Wrapper for running any of the European hydraulic PTFs based on the European HYdropedological Data Inventory enclosed in package euptf on a stack of raster layers (RasterStack.)

Usage

predict.ptf(dataStack, PTF, filename, format="GTiff", overwrite = !file.exists(filename), transfo=NULL)

Arguments

dataStack

RasterStack containing layers with the predictors. The predictors referred to in PTF must be present as named layers in dataStack. To get the correct names, follow example: data(ptf.data). // Layers containing the categorical variables TEXT_FAO_MOD, TEXT_US, TOPSOIL should use the numbered coding as given in psd2classFAO_MOD, psd2classUS and TOPSOIL=1 for topsoil and TOPSOIL=2 for subsoil.

PTF

Name of the PTF to be run, as a character. Any of ("PTF01","PTF02",...,"PTF15").

filename

Output filename. Character

format

Output file format. Character. See raster::writeFormats. Defaults to "GTiff".

overwrite

Should existing "filename" be overwritten? Logical. Defaults to FALSE.

transfo

List of transformations to operate on the predictors before running the PTFs, e.g. list(PH_H2O='/10',BD='/1000'). For details on the units required by the PTFs, see euptf-package.

Value

A RasterLayer or RasterBrick object.

Warning

The pedotransfer functions in this package use the following units:

Length: centimeter
Time: day
Mass: gram

Author(s)

M. Weynants

See Also

ptf.data, ChoosePTF, raster:raster, raster:RasterStack

Examples

# load example data
data(ptf.data)
# set modified FAO texture class
ptf.data$TEXT_FAO_MOD <- psd2classFAO_MOD(ptf.data$USSAND,ptf.data$USSILT,ptf.data$USCLAY,ptf.data$OC,option=FALSE)
# set USDA texture class
ptf.data$TEXT_US <- psd2classUS(ptf.data$USSAND,ptf.data$USSILT,ptf.data$USCLAY,ptf.data$OC,option=FALSE)
# reset TOPSOIL to numeric
ptf.data$TOPSOIL <- as.numeric(ptf.data$TOPSOIL)-1;ptf.data$TOPSOIL[ptf.data$TOPSOIL==0]<-2
# create a RasterStack
s <- brick(ncol=10,nrow=10,nl=ncol(ptf.data))
ind <- sort(sample(1:100,60))
m <- matrix(NA,ncol=ncol(ptf.data),nrow=ncell(s))
m[ind,] <-  as.matrix(ptf.data,ncol=ncol(ptf.data))
s <- stack(setValues(s, as.numeric(m)))
names(s) <- names(ptf.data)
# examples of usage of predict.ptf.raster
ths_fao <- predict.ptf.raster(s,"PTF01",filename='tmp1.tif')
fc_usda <- predict.ptf.raster(s,"PTF07",filename='tmp2.tif')
wp_psd_OC <- predict.ptf.raster(s,"PTF10",filename='tmp3.tif')

### Parameters estimation of Mualem-van Genuchten model
## if only MRC is needed
# get van Genuchten parameters
vg_psd_oc_bd_ph <- predict.ptf.raster(s,"PTF22",filename='tmp4.tif')
## if both MRC and HCC are needed
# get Mualem-van Genuchten parameters
mv_psd_oc_bd_ph <- predict.ptf.raster(s,"PTF19",filename='tmp5.tif')

melwey/euptf documentation built on Sept. 17, 2022, 3:35 a.m.