Learn R Programming

GSIF (version 0.3-1)

mpspline: Fits a mass preserving spline

Description

Fits a mass preserving spline to a soil profile data.

Usage

## S3 method for class 'SoilProfileCollection':
mpspline(obj, var.name, 
      mxd = 200, lam = 0.1, d = t(c(0,5,15,30,60,100,200)), 
      vlow = 0, vhigh = 1000)

Arguments

obj
object of class "SoilProfileCollection"
var.name
character; target variable name (must be a numeric variable)
mxd
numeric; maximum depth to which spline should be fitted
lam
numeric; lambda the smoothing parameter
d
numeric; standard depths
vlow
numeric; smallest value of the target variable (smaller values will be replaced)
vhigh
numeric; highest value of the target variable (larger values will be replaced)

Value

  • Returns a list with four elements: [object Object],[object Object],[object Object],[object Object],[object Object] All detphs are commonly expressed in centimeters. The returned values refer to point support and can be used to construct a "SpatialPointsDataFrame" (3-dimensional).

References

  • Bishop, T.F.A., McBratney, A.B., Laslett, G.M., (1999)http://dx.doi.org/10.1016/S0016-7061(99)00003-8{Modelling soil attribute depth functions with equal-area quadratic smoothing splines}. Geoderma, 91(1-2): 27-45.
  • Malone, B.P., McBratney, A.B., Minasny, B., Laslett, G.M. (2009)http://dx.doi.org/10.1016/j.geoderma.2009.10.007{Mapping continuous depth functions of soil carbon storage and available water capacity}. Geoderma, 154(1-2): 138-152.

See Also

stats::spline

Examples

Run this code
library(aqp)
library(plyr)
## sample profile from Nigeria:
lon = 3.90; lat = 7.50; id = "ISRIC:NG0017"; FAO1988 = "LXp" 
top = c(0, 18, 36, 65, 87, 127) 
bottom = c(18, 36, 65, 87, 127, 181)
ORCDRC = c(18.4, 4.4, 3.6, 3.6, 3.2, 1.2)
munsell = c("7.5YR3/2", "7.5YR4/4", "2.5YR5/6", "5YR5/8", "5YR5/4", "10YR7/3")
## prepare a SoilProfileCollection:
prof1 <- join(data.frame(id, top, bottom, ORCDRC, munsell), data.frame(id, lon, lat, FAO1988), type='inner')
depths(prof1) <- id ~ top + bottom
site(prof1) <- ~ lon + lat + FAO1988 
coordinates(prof1) <- ~ lon + lat
proj4string(prof1) <- CRS("+proj=longlat +datum=WGS84")
# fit a spline:
ORCDRC.s <- mpspline(prof1, var.name="ORCDRC")
str(ORCDRC.s)

Run the code above in your browser using DataLab