Soil salinization models for soil health assessment

Omuto, CT

Correct citation:

Omuto, CT (2025). Soil salinization models for soil health assessment, in: soilassessment R package. CRAN. https://doi.org/10.32614/CRAN.package.soilassessment

1 Introduction

Salinization is a type of soil degradation due to salt accumulation in the soil (Artzy and Hillel, 1988; Omuto et al., 2022; Rengasamy, 2006). It increases the magnitude of forces (or osmotic potential) holding soil moisture and nutrients. The increase may go beyond the ability of roots of most plants to extract the soil moisture or nutrients and consequently denying the plants access to these vital soil resources for their growth and development. The high force can also practically extract moisture from bodies of living organisms or plant roots in such soils through the osmotic gradient between the bodies of these organism or plant roots and the soil. Therefore, soils experiencing salt accumulation often exhibit restricted biodiversity, low bioavailability of soil moisture and nutrients, increased toxicity, and low biomass and agricultural productivity (Daliakopoulos et al., 2016; Kihara et al., 2020; King et al., 2022). In general, salinization negatively affects soil health. There are many methods in the literature for quantifying salinization, which imply that some sort of standardization is necessary to harmonize applications in soil health assessment. The soilassessment package presents an open-source library of models for digital assessment of soil salinization.

Popularly used indicators for quantifying levels of salt accumulation in the soil are electrical conductivity (EC), exchangeable sodium percent (ESP), sodium adsorption ratio (SAR), pH, total soluble salts (TSS), or total dissolved solids (TDS) (Abrol et al., 1988; Chhabra, 2004; Richards, 1954). The most popular indicators are EC, pH, and ESP or SAR. These indicators have different thresholds for identifying levels of salt accumulation in the soil. The thresholds need harmonization to communicate the same level of salt accumulation. Besides harmonization of indicator thresholds, the methods for measuring the indicators also need standardization. The usual measurement procedure is to dilute a known mass of soil with a known volume of water and using extract solution from the mixture to measure the soil indicator (Haldar et al., 2021; Rhoades, 2018). Most methods differ on the proportions of the soil-water mix ratios. Higher water proportions can result in more diluted extract solution and portray a different level of concentration of salts in the soil than the case with extract solutions from a saturated paste for the same soil. These differences occasioned the recommendation to use extract solutions from a saturated soil paste as the standard for measuring indicators for evaluating salt levels in the soil (FAO, 2006; Richards, 1954). This implies that measurements taken in other extract solutions need to be harmonized to the equivalent values of the extract from a saturated soil paste. Several attempts have been made in the literature to develop harmonization models for converting values of salt indicators in other extract solutions to the equivalent values in the extract from a saturated soil paste (Omuto et al., 2023). Here it shown how these models can be used in the R environment to facilitate harmonized assessment of salt accumulation in the soil.

Indicators for salt accumulation in the soil can be determined by direct measurement on soil samples in a laboratory or in-situ in the field. Laboratory measurements are deemed as more accurate and less varied compared to in-situ measurements (Rhoades et al., 1999). Therefore, laboratory measurements are often used to calibrate other measurement methods. In-situ measurements are rapid and involve either placing the measuring device/sensor in the soil or at a proximal distance from the soil. Apart from using soil indicators, assessment of soil salts has also been evaluated using surrogate indicators such as remote sensing images, plant growth characteristics, delineations from soil maps, salt levels in groundwater, etc. (Shahid et al., 2018). These surrogates or in-situ measurements also need harmonization with laboratory measurements to convey the same message on salt levels in the soil. This document shows how the surrogates can be standardized and correlated with soil indicators to assess soil salinization in the landscape.

2 Library of salinization models in soilassessment package

2.1 Harmonization models

The soilassessment package contains three groups of harmonization models: 1) parametric models from the literature; 2) expressions for developing pedotransfer functions; and 3) expressions for developing own harmonization models (Omuto et al., 2023). Equation \(\ref{eq:1}\) is the general format for the harmonization models.

\[ y = f ( x, \theta ) \tag {1} \label{eq:1} \]

where y is the harmonized soil indicator, x is the indicator value to harmonize, and \(\theta\) is a set of coefficients (regression parameters) of the f harmonization model. The soilassessment contains more than 30 harmonization models (Omuto et al., 2023). Information about these models can be queried using the function SASmodels. The query needs two arguments: the type of soil indicator the models target (e.g., “ec” for electrical conductivity) and soil-water ratio for the extract solution in which the indicator was measured (e.g., “1:1”). The following example shows how the query is implemented using the function SASmodels:

library(soilassessment)
SASmodels("ec","1:1")
#>   extract  model texture
#> 1     1:1    FAO     yes
#> 2     1:1 sonmez     yes
#> 3     1:1   hogg     yes
#> 4     1:1 landon      no
#> 5     1:1 kargas      no
#> 6     1:1  ozkan      no
#> 7     1:1   USDA      no
#> 8     1:1   hogg      no
#> 9     1:1  zhang      no

The query returns information about the extract solutions, names of the harmonization models, and whether the models require soil texture to harmonize the target soil indicator. Soil texture information is included in the query output because some models use it to model the harmonization.

2.1.1 Harmonization using parametric models from literature

Most salinization models in the soilassessment package are collections of parametric equations from the literature. They are grouped as either purely fixed-effect or mixed-effects models (Omuto et al., 2023). Fixed-effects models are average regression models of the form given in Equation \(\ref{eq:2}\).

\[ y_{i} = f (x_{i},\theta) + \epsilon_{i}\tag{2} \quad\text{for}\ {1 \leq i \leq n} \label{eq:2} \]

where yi is a vector of target variable, xi is a vector of soil indicator to harmonize, \(\epsilon_i\) is the random residual, n is the number of samples, and \(\theta\) is a set of coefficients (also known as fixed effects).

Fixed-effects models are regression models depicting the average relationship between x and y. They were developed with the assumption that a regression model is sufficient to represent the harmonization relationship between x and y without regards to any potential differences between natural soil groupings. Natural soil groupings such as texture or soil types affect soil properties and should not be ignored in soil property modelling. Mixed-effects models differ from the fixed-effects models in the way they treat grouping factors like texture, soil depth, climatic zones etc., which are known to influence salt characteristics in the soil (Seo et al., 2022; Shahid et al., 2018). Mixed-effects models not only recognize the grouping factors but also incorporate them in the modelling algorithms (Pinheiro and Bates, 2000). The format for mixed-effects models is given in Equation \(\ref{eq:3}\) and contains \(\phi\) model-fitting parameters comprising \(\theta\) fixed-effects and bj random-effects for each of the m grouping variables, and \(\epsilon_i\) random residuals.

\[ y_{ij} = f (x_{ij}, \phi_{j}) + g (\epsilon_{ij}) , \qquad\phi_{j} = \theta + b_{j} \qquad\text{ for}\ {1 \leq i \leq n} \qquad\text{and} \qquad\text{for}\ {1 \leq j \leq m} \qquad \tag{3} \label{eq:3} \]

where g is a function for the residual model.

Mixed-effects or fixed-effects harmonization models in the soilassessment package are implemented by specifying the function for the model, type of soil indicator to harmonize, model name, and the extract solution involved. Soil textural classes are optional for the models that require their use. There are five groups of functions in the soilassessment package for implementing harmonization models from the literature:

  1. The function ECconversion 1: for fixed-effects models in different soil textural classes
  2. The function ECconversion 2: for fixed-effects models which do not use soil texture
  3. The function ECconversion 4: for harmonizing EC and TSS or TDS
  4. The function ME_ECharm : for mixed-effects models to harmonize electrical conductivity (EC)
  5. The function ME_PHharm : for mixed-effects models to harmonize pH

The first group of functions are for models in the library which use fixed-effects equations. The equations were developed separately for each soil textural classes. The second group of functions are for fixed-effects models in the library where soil textural classes are not required. The fourth and the fifth groups use mixed-effects approach. The third group is for library models that harmonize TSS or TDS with EC of saturated soil paste extract (ECse). The following example shows how these harmonization models can be implemented in the soilassessment package. The example uses EC2 data (EC in 1:2 extract solution) which need to be harmonized into ECse.

# Get the data
EC2=c(1,1.4,0.8,0.3,0.3,1.3,2.8,0.7,0.6,3.5,1.5,2.5,0.9,0.5,0.8)
ECse=c(1.5,2.9,1.7,0.7,0.6,3,4.1,1.1,2.1,6,1.7,4.7,3,1.1,2)
texture=c("Cl","Cl","SiLo","Si","SiLo","Si","Lo","Lo","SaLo", "SaLo","LoSa",
          "LoSa","LoSa","SiClLo","SiClLo")
soild = data.frame(EC2,ECse,texture) 

# Harmonize using a fixed-effects model without use of soil texture
soild$ECse1=ECconversion2(soild$EC2,"USDA","1:2") 
predAccuracy(soild$ECse,soild$ECse1)$Rsquared 
#> [1] 0.8611294

# Harmonize using a mixed-effects model
soild$ECse2=ME_ECharm(soild$EC2,soild$texture,"linear","1:2") 
predAccuracy(soild$ECse,soild$ECse2)$Rsquared
#> [1] 0.8434537

2.1.2 Harmonization using pedotransfer function

Pedotransfer function (PTF) is a mathematical model between soil properties in a soil database. PTFs are often developed between readily available and easily measurable soil properties and soil properties which are cumbersome and expensive to measure. They have been popularly used to estimate missing soil properties in a database (Van Looy et al., 2017). Readily available soil properties which are often used in PTFs to estimate target indicators of salts in the soil are textural proportions (percent sand, silt, and clay contents), organic carbon content, pH, cation exchange capacity (CEC), and exchangeable ions. Equation \(\ref{eq:4}\) is a general PTF format where the function f represents the PTF.

\[ y_{i} = f (x_{i},\theta) + \epsilon_{i}\tag{4} \quad\text{for}\ {1 \leq i \leq n} \label{eq:4} \] where yi is the vector of target variables, xi is a set of the predictor soil properties, \(\epsilon_i\) is the random residual, and n is the number of samples. The term \(\theta\) is optional for parametric models and represents a set of model-fitting parameters.

The soilassessment package allows for the development of PTFs using algorithms for linear regression (here denoted as linear), support vector machine (svm), random forest (randomforest), neural network (neuralnetwork), etc. These algorithms are also popularly used in soil science (Wadoux et al., 2020). PTFs are implemented in the soilassessment package using the function pedoTransfer. Arguments for this function include the target algorithm, data frame containing the target soil indicator to be harmonized, and a set of independent soil properties (predictors) to predict the target soil indicator. The PTFs need appropriate evaluation before using them. Table 2.1 is an example data for demonstrating the potential of PTF in gap-filling and harmonization. It contains gaps (NAs) in EC5 data (EC in 1:5 extract solution). The data is an extract from the global soil database for an area in southern Nigeria (Batjes et al., 2020).

The code below shows how PTFs are built in the soilassessment package using pedoTransfer function. Model building strategy where the data is split into two is recommended to provide data for model building and testing (Joseph, 2022). One part of the split data is used in developing the PTF and the other part is held-out for evaluating the PTF. Different PTF algorithms in the soilassessment package may be tested to arrive at the most suitable one for the dataset.

Table 2.1: Sample soil database for PTF development
EC5 Sand Silt Clay pH OC Ca Mg K Na CEC BS
0.081 68.0 14.00 18.00 5.800 1.800 2.800 0.700 0.070 0.040 4.600 78.48
0.090 59.0 28.00 13.00 6.300 4.600 2.800 0.800 0.110 0.210 5.500 71.27
0.093 34.0 28.00 38.00 6.200 3.670 4.600 1.900 0.180 0.110 2.500 70.00
0.100 50.0 24.00 26.00 7.400 7.620 5.000 2.000 0.340 0.230 10.200 74.20
NA 72.0 8.00 20.00 6.100 2.400 1.200 0.300 0.420 0.280 2.000 50.00
0.102 54.0 12.00 34.00 5.600 0.600 5.600 2.300 0.100 0.070 8.600 70.60
0.130 59.0 32.00 9.00 6.800 6.100 3.200 1.300 0.180 0.170 6.400 75.78
0.150 52.0 24.00 24.00 7.300 3.990 4.600 1.700 0.300 0.100 7.400 90.50
0.160 58.0 36.00 6.00 7.000 4.100 2.500 0.900 0.360 0.350 4.700 87.06
NA 82.0 10.00 80.00 7.500 5.750 1.400 0.300 0.150 0.070 2.600 73.80
0.180 44.0 30.00 26.00 7.300 6.220 9.600 3.400 1.130 0.100 15.100 94.20
0.200 43.0 44.00 13.00 6.100 15.600 3.200 1.600 0.320 0.180 6.800 77.94
NA 48.7 21.20 30.10 5.775 0.605 7.195 3.095 1.235 0.890 12.810 33.17
NA 85.2 11.20 3.60 5.090 0.400 1.075 0.325 0.160 0.190 5.840 29.96
NA 84.6 8.10 7.30 5.355 0.565 1.750 1.465 0.585 0.360 7.270 69.55
NA 61.9 16.85 21.25 6.460 0.950 4.915 2.290 1.090 0.285 9.310 92.16
NA 58.1 19.20 22.70 6.425 0.945 3.860 1.675 1.675 0.455 12.275 62.44
NA 85.0 9.40 5.60 5.490 0.420 1.200 0.575 0.205 0.235 3.080 71.92
# select part of the data without NAs
psoil1=subset(psoil,!is.na(psoil$EC5)) 
# Randomly split data into two: 75% for training and 25% held-out for testing 

set.seed(40)
bound = floor((nrow(psoil1)/3)*2)
randomsample = sample(nrow(psoil1))
Train = psoil1[randomsample, ][1:bound, ]
Test = psoil1[randomsample, ][(bound+1):nrow(psoil1[randomsample, ]), ]
ptf=pedoTransfer("randomforest",Train,EC5,Sand,Silt,Clay,pH,OC,Mg,K,Na,CEC,BS)
Test$EC5p=predict(ptf,newdata = Test)
predAccuracy(Test$EC5,Test$EC5p)$Rsquared
#> [1] 0.1311012

PTF harmonization is used in the soilassessment package in two ways: 1) to gap-fill missing entries of a target variable, and 2) to develop a harmonization model between a standard salt indicator and other soil properties. It may be necessary to evaluate the output of the PTF harmonization using a graphical summary such as the histogram to check whether the harmonization model preserved the empirical distribution of the data (Figure 2.1).

Test Histogram comparison in PTF harmonization.

Figure 2.1: Test Histogram comparison in PTF harmonization.

2.1.3 Developing own harmonization models using functions in soilassessment

More harmonization models are needed to complement the models in the soilassessment package. These additional models may be necessary to handle extract solutions other than those considered in the soilassessment package or to harmonize salt indicators which have not been adequately covered by the current models in the soilassessment package. New models may also be needed in areas where the soilassessment package models have inadequacies such as in poorly sampled parts of the world. All these cases may prompt the need to develop own harmonization models. The soilassessment package contains the function ECconversion 3 which can facilitate development of own harmonization model. ECconversion 3 allows model building using machine learning algorithms such as random forest, cart, svm, cubist, etc. The following code example illustrates how to develop own harmonization model using ECconversion 3(). In the example, data on apparent electrical conductivity (ECa) from an electromagnetic induction (EM38) and the corresponding EC of saturated soil paste extract (ECse) are used. The data was obtained from a study of soil salinity in an irrigation project in Taita Taveta County in Kenya in 1992 (Dooremolen, 1992). It contained 13 observations on soil surface (0-30 cm) in a 50m by 50m farm. The harmonization model is shown in Figure 2.2.

# Get the data and convert into a dataframe
x=c(0.78,1.071,0.048,0.967,0.91,0.429,0.282,0.743,0.499,0.197,
    0.922,0.209,0.364) # ECa data
y=c(10.411,12.887,1.769,9.962,11.18,5.452,3.574,6.443,7.952,4.258,
    9.774,7.311,9.984) # ECse data
xy=data.frame(cbind(x,y))
names(xy)=c("ECa", "ECse")
# Fit an exponential model
strt=c(A=0.1, B=0.8)
EC3.ml=nls(ECse~ECconversion3(ECa,A,B, "exponential"), 
           start=strt, data=xy)
predAccuracy(fitted(EC3.ml),xy$ECse)$Rsquare
#> [1] 0.6683013
plot(ECse~ECa,xy, xlab="Apparent EC (ECa, dS/m)",
     ylab = "Measured EC (ECse, dS/m)")
lines(xy$ECa[order(xy$ECa)], predict(EC3.ml,
     newdata=xy[order(xy$ECa),]),col="red")
Example of own harmonization model

Figure 2.2: Example of own harmonization model

2.2 Models for using remote sensing images and other spatial data

The soilassessment package also contains functions to accommodate use of factors influencing the distribution of salt in the soil. These factors are topography, climate, geology, hydrogeology, land use, proximity to salty water bodies such as seawater, groundwater, etc. The literature recommends considering these factors when assessing salt accumulation in the soil (Omuto et al., 2020). Spatial data representing these factors are remote sensing images and maps of soil types, geology, hydrogeology, elevation, climate, and land cover. They can be integrated into salt assessment through modelling. Besides modelling, there are also applications which have used reflectance from remote sensing images to directly assess the distribution of salt levels in the soil (Asfaw et al., 2018). Reflectance of remote sensing images contain integral information of land surface characteristics which can represent some of the factors influencing salt distribution in the soil. The reflectance can be directly correlated with soil surface characteristics or indirectly through image indices to assess occurrence and distribution of salts in the soil (Nguyen et al., 2020; Omuto et al., 2020). Many remote sensing image indices have been developed in the literature to support assessment of salts in the soil (Table 2.2). The soilassessment package contains the function imageIndices for deriving these image indices.

Table 2.2: Remote sensing indices for salts distribution in soil
Image Bands Image Index Estimation Model
swir1(b6),nir(b5),swir2(b7) NSI \((b6-b7)/(b6-b5)\)
green(b3),red(b4) SI1 \(\sqrt{(b4*b3)}\)
blue(2),red(4) SI2 \(\sqrt{(b4*b2)}\)
green(b3),red(b4) SI3 \(\sqrt{(b4^2*b3^2)}\)
swir1(b6),nir(b5) SI4 \((b5*b6-b6^2)/b5\)
blue(2),red(b4) SI5 \(b2/b4\)
red(b4),nir(b5),green(b3) SI6 \(b4*b5/b3\)
nir(b5),red(b4) SAVI \((b5-b4)/((b5+b4+0.5)*1.5\))
green(b3),red(4),nir(b5) VSSI \(2*b3-5*(b4+b5)\)
red(b4),nir(b5) NDSI \((b4-b5)/(b4+b5)\)
red(b4),nir(b5) NDVI \((b5-b4)/(b5+b4)\)
blue(2),green(b3),red(4) SR \((b3-b4)/(b2+b4)\)
blue(2),green(b3),red(4),nir(5) CRSI \(\sqrt{(b5*b4-b3*b2)/(b5*b3+b3*b2)}\)
green(b3),red(b4),nir(b5) BI \(\sqrt{b3^2+b4^2+b5^2}\)

The following code shows how to use the function imageIndices to derive remote sensing image indices for assessing the presence of salts in the soil. Inputs for the function are image bands of reflectance (blue, green, red, near infrared (nir), and shortwave infrared - (swir1 and swir2)) and the target image index for soil salt (Table 2.2). The input image bands can be supplied individually or as a stack of images. It is important to ensure that the input image bands are compatible in terms of temporal and spatial resolutions as well as the geographic extent and projection. Examples of outputs from the imageIndices function are shown in Figure 2.3.

library(raster)
#> Loading required package: sp
library(rasterVis)
#> Loading required package: lattice
green=raster("green.tif")
blue=raster("blue.tif")
red=raster("red.tif")
nir=raster("nir.tif")
swir1=raster("swir1.tif")
swir2=raster("swir2.tif")
SI1=imageIndices(blue,green,red,nir,swir1,swir2,"SI1")
NDSI=imageIndices(blue,green,red,nir,swir1,swir2,"NDSI")
SR=imageIndices(blue,green,red,nir,swir1,swir2,"SR")

names(SI1)=c("SI1")
names(SR)=c("SR")
names(NDSI)=c("NDSI")
levelplot(stack(SI1, SR, NDSI), scales =list(draw=TRUE),
          col.regions = terrain.colors(255), 
          colorkey = list(space = "right"))
Examples of image indices for salt distribution in soil

Figure 2.3: Examples of image indices for salt distribution in soil

#> Warning in sqrt(getValues(x)): NaNs produced

Remote sensing indices can also be integrated with other factors to model the spatial distribution of salt in the soil. Several modelling algorithms are available in the literature for this purpose. The soilassessment package has a function for searching for suitable models and guide selection of the appropriate algorithm. It contains the function regmodelSuit which can search and report modelling statistics for top performing algorithms for the dataset. It tests potential algorithms on a dataset and reports their performance statistics such as mean error (ME), root mean square error (RMSE), correlation (r2) and Nash-Sutcliffe coefficient of efficiency (NSE). These statistics provide the guideline for selecting the most suitable algorithm. Models with the lowest ME and RMSE and the highest r2 and NSE should be preferred.

It is important to note the following points when preparing data for use with the function regmodelSuit (Omuto et al., 2020):

The following code example shows how the data is first prepared and organized. Environmental covariates used are remote sensing indices of salt in soil, climate variables (such as maximum and minimum temperature and rainfall), land cover, and topographic terrain parameters (such as slope, length of slope, plan curvature, channel network to base level - cnbl, etc.) (Omuto et al., 2020).

#Prepare and organize environmental covariates as predictors
dem=raster("dem.asc")
ls=raster("ls.asc")
slope=raster("slope.asc")
valley=raster("valley.asc")
cnbl=raster("cnbl.asc")
plan=raster("plan.asc")
maxtemp=raster("maxtemp.tif")
mintemp=raster("mintemp.tif")
lcover=raster("lcover.tif")
rain=raster("rain.tif")
dem=raster("dem.asc")
#stack the predictors
predictors=stack(BI,CRSI,NDSI,NDVI,NSI,SAVI,SI1,SI2,SI3,SI4,SI5,SI6,SR,
                 VSSI,dem,ls,slope,cnbl,plan,valley,maxtemp,mintemp,
                 rain,lcover)
names(predictors)=c("BI","CRSI","NDSI","NDVI","NSI","SAVI","SI1","SI2",
                    "SI3","SI4","SI5","SI6","SR","VSSI","dem","ls",
                    "slope","cnbl","plan","valley","maxtemp","mintemp",
                    "rain","lcover")

Some times it is necessary to reduce the data dimensionality where there are more predictors than the number of cases of the target soil variable to be modeled. Principal Component Analysis (PCA) is one of the methods for reducing predictors to a few principal components (PCs) (Greenacre et al., 2022). The following code example shows how PCA can be used to reduce 14 image indices to a few PCs. A scree plot of the PCs (Figure 2.4) can aid selection of a suitable number of PCs which account for more than 95% of the information content in the original set of image indices.

library(factoextra)
#> Loading required package: ggplot2
#> Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
predictors2=(predictors[[1:14]])
pred.val = getValues(predictors2)
pr.id = which(!is.na(pred.val)) 
pca = princomp(pred.val, cor=T)
fviz_eig(pca) # scree plot
Scree plot for choosing a suitable number of PCs

Figure 2.4: Scree plot for choosing a suitable number of PCs

ncomp = 5 # Selected number of PCs
pr.pca <- predictors2[[1:ncomp]]
for(i in 1:ncomp) { pr.pca[[i]][pr.id] <- pca$scores[,i] } 
names(pr.pca)=c("PC1","PC2","PC3","PC4","PC5")
predicters=stack(pr.pca$PC1,pr.pca$PC2,pr.pca$PC3,pr.pca$PC4,pr.pca$PC5,
                 dem,ls,slope,cnbl,plan,valley,maxtemp,mintemp,rain,lcover)

In this documentation, a sample soil data was used with the environmental covariates to show how to build the spatial relationship for mapping indicators of salts in the soil. The sample soil data contains measured soil properties from 78 sampling locations in southern Kenya. Each sampling location had more than four samples at varied depth intervals in a soil profile. A spatial distribution of the sample soil data is shown in Figure 2.5.

soil=shapefile("soildata.shp")
bubble(soil, "pH", scales = list(draw=TRUE), main= NA, 
       maxsize = 2)
Example of locations of soil pH data from southern Kenya

Figure 2.5: Example of locations of soil pH data from southern Kenya

The pixel values of the covariates are extracted and appended onto the soil data as shown in the following example.

#Import the point shapefile and extract predictor pixel values
soil1=extract(predictors, soil)
soil2 =cbind(soil,soil1)
#organize the target and predictor into dataset for modelling
soilp=soil2[,c("EC5","TEXCLASS","ECse","pH","ESP","BI","CRSI","NDSI",
               "NDVI","NSI","SAVI","SI1","SI2","SI3","SI4","SI5","SI6",
               "SR","VSSI","dem","ls","slope","cnbl","plan","valley",
               "maxtemp","mintemp","rain","lcover")]
soilp=data.frame(soilp)

When using regmodelSuit function, the first argument is the dataset containing modelling variables, the second argument is the target variable to model, and the subsequent variables are the predictors. The names of the variables in the dataset must correspond to the names of the arguments supplied to the regmodelSuit function. The function may take time to complete the process especially where a large dataset is involved. The output is a table showing evaluation statistics for top suitable models for the dataset (Table 2.3).

soilec =soilp[, colnames(soilp)[c(3, 6:29)]]
regmodelSuit(soilec,ECse,BI,CRSI,NDSI,NDVI,NSI,SAVI,SI1,SI2,SI3,SI4,SI5,SI6,
             SR,VSSI,dem,ls,slope,cnbl,plan,valley, maxtemp,mintemp,rain,
             lcover)# NB: This part can take time
Table 2.3: Evaluation statistics for modelling algorithms in regmodelSuit function
Algorithm ME RMSE R2 NSE
Linear 0.4980970 0.9221965 0.4131760 0.0545453
RandomForest 0.3200139 0.8874233 0.6415919 0.4811995
SVM 0.4051999 1.0922583 0.3448001 -5.9226998
BayesianGLM 0.4860159 0.9464917 0.4202483 -0.3776671
BaggedCART 0.4032268 0.8978902 0.4444890 0.0577982
Cubist 0.3010037 0.8355491 0.5804149 0.5111329
CART 0.4544668 1.0954523 0.2593884 -0.0213372
Ranger 0.3285088 0.9232545 0.5128640 0.4577277
QuantRandForest 0.3236330 1.0494950 0.4848026 -0.6961260
QuantNeuralNT 0.3827372 1.1198034 0.4613748 -4.2935941

Analysis of the output of the function regmodelSuit in Table 2.3 shows that the randomForest, cubist, and ranger were likely the best algorithms for spatial modelling of salt levels in the sample data. They had low ME and RMSE and high r2 and NSE. Any of these three algorithms can be selected for modelling the spatial distribution of the target variable as shown in the following example code. Example output prediction is shown in Figure 2.6.

library(caret)
#summary(soilp$EC5) #Check for missing values
#soilp =subset(soilp, !is.na(soilp$EC5)) #Remove missing data
# Mixed-effects polynomial model
soilp$ECse_pl=ME_ECharm(soilp$EC5,soilp$TEXCLASS, "polynomial","1:5")
# Mixed-effects linear model
soilp$ECse_lin=ME_ECharm(soilp$EC5,soilp$TEXCLASS, "linear","1:5")
trCl=trainControl( method = "cv",number=5,returnResamp = "all",
                   savePredictions = TRUE, search = "random",
                   verboseIter = FALSE)
ec.m=train(sqrt(ECse_pl)~(BI+CRSI+NDSI+NSI+SAVI+SI1+SI2+SI3+SI4+SI5+SI6+SR+
                             VSSI+ dem+ls+slope+cnbl+plan+valley+maxtemp+
                             mintemp+rain+lcover),soilp, method = "rf",
            trControl=trCl) # Repeat for linear harmonization model
ECse=(predict(predictors, ec.m))^2
Spatial distribution of EC, pH, and ESP

Figure 2.6: Spatial distribution of EC, pH, and ESP

2.3 Models for classification of levels of salt content in soil

Classification of soil attempts to put different soils into groups of similar characteristics. It provides the general guidelines for estimating characteristics of any soil in the group since all soils in each class are assumed to have the same behavior or characteristics. Most salt classification schemes in the literature use EC, pH, and ESP or SAR to group soils into different classes. Popularly used classes are saline, saline-sodic, and sodic, because they represent majority of problematic and widespread salt-affected soils worldwide (Abrol et al., 1988; Szabolcs, 1989). Classification schemes identify these classes using certain thresholds on pH, EC, and ESP or SAR. The most popular schemes are those proposed by FAO and USDA (Omuto et al., 2020). Figure 2.7 is an example of a classification scheme by FAO (FAO, 2006).

FAO salt classification scheme

Figure 2.7: FAO salt classification scheme

The soilassessment package contains the function saltSeverity for implementing popularly used salt classification schemes. Its implementation requires a list of the soil indicators for the classification and the preferred classification scheme. The following example illustrates how to implement saltSeverity function for estimating salt levels in the soil using FAO classification scheme in Figure @ref(fig:SAStree0.

#> terra 1.8.5

Saltlevel=saltSeverity(values(ec1$ECse),values(ph1$PH),values(esp1$ESP),
                       "FAO")
esp1$salt=Saltlevel
esp1$salta=classCode(values(esp1$salt),"saltseverity")
# 
par(mfrow=c(1,2))
pal=c("magenta","brown","yellow","white","gray","cyan","green"
      ,"peachpuff1",  "orange","red")
plot(esp1$salta2,cex.main=1, cex=2,col=pal, main="(a) Linear model")
plot(esp1$salta, cex.main=1,cex=2, col=pal2, 
     main="(b) Linear mixed-effects model",legend=FALSE)
Example of distribution of salt levels

Figure 2.8: Example of distribution of salt levels

The distribution of salt classes in Figure 2.8 demonstrate the impact of not selecting appropriate harmonization models. It shows results of a linear harmonization model that did not consider soil texture and that of a mixed-effects harmonization model which considered soil texture. Comparison of the performance of the harmonization models revealed that the linear model did not only poorly harmonize high EC but also had low overall performance compared to the linear mixed-effects model. Consequently, the linear model produced more areas with high salinity than the case with the linear mixed-effects (Figure 2.8).

3 Soil health assessment services

3.1 Decision support for selection of appropriate assessment models

The library of models in the soilassessment package provides tools for harmonizing input data for salt assessment, for quantifying distribution of soil salts, and for classifying salt levels in the soil. Not only does the package contains a library of assessment models in a single collection but also has functions for providing necessary information about these models. This information (or metadata) is useful in guiding selection of appropriate models for different use cases. Without these pieces of information, the decision on which model for any use-case may not be easy leading to a possible inaccurate assessment due to application of inappropriate assessment tools. The following are some of the package functions which generate information for guiding selection of appropriate assessment models:

  1. The function SASmodels: For searching for information on available harmonization models in the library.
  2. The function ECharm_Info: shows relative performance of EC models in different parts of the world (Figure 3.1)
  3. The function PHharm_Info: shows relative performance of pH models in different parts of the world
  4. The function regmodelSuit: For identifying a suitable machine learning algorithm to model the relationship between a soil property and other properties (or environmental covariates in DSM)

The following is an application example for generating information on relative performance of EC harmonization models in different parts of the world (Figure 3.1):

SASmodels("ph", "kcl")
ECharm_Info("1:5") #Global performance of EC models
PHharm_Info("cacl2") #Global performance of pH models
Performance comparison for EC5 models

Figure 3.1: Performance comparison for EC5 models

3.2 Promoting development of harmonization models

The facility for supporting development of own harmonization model is an important service within the soilassessment package to promote wide use of different data sources for assessing salt levels in the soil. Since harmonization models in the soilassessment package do not completely cover all use cases, the package allows room for development of new models by the user community. The function ECconversion 3 provides the service for developing new harmonization models. This is particularly important for cases that have not been adequately covered by the soilassessment package, for example proximal sensors such as electromagnetic induction (EMI), gamma ray induction, infrared spectroscopy, etc. (Dierke and Werban, 2013; Lesch et al., 1995). Presently, the soilassessment package does not have widely tested harmonization models for proximal sensors.

The function pedoTransfer is another function in the soilassessment package which allows users to develop harmonization and gap-filling services with readily available/measurable soil properties. The function pedoTransfer can also help users to make use of available soil data to improve their soil database regarding poorly sampled soil properties in the database. This function may also be useful for other soil health indicators apart from indicators of salt levels.

3.3 Query service for data availability in a database

Searching for specific data in a database is a common challenge in soil data analysis. Most users of soil data are often confronted with the need to search for data availability of certain soil health indicators in existing soil database. The search can be daunting depending on the size of the existing database, type of data, tools for search, etc. The soilassessment package contains the function DataAvailabilityIndex for supporting data search on databases with spatial references. The function targets the number of distinct locations in the database which matches the search criteria and gives the output in form of a spatial map of density of sampling locations (or number of sampling locations per unit area).

The function requires information about the boundary of area of interest (aoi) for which data is sought, search radius in km, spatial coordinate reference system, and the database to be searched. The following example shows how the function can be used to search for the number of locations with pH data in the sample soil database in Figure 2.5. The output is a map of density of data availability within the search radius (Figure 3.2).

# Choose extent for data search and assign projection
x=c(36.935,38.4)
y=c(-2.52,-1.52)
CrS="+proj=longlat +datum=WGS84 +no_defs"
xy <- as(raster::extent(x,y), "SpatialPolygons")
crs(xy)= CrS

par(mfrow=c(1,2), mar=c(2,0,2,2),mgp=c(2,0.7,2))
plot(soil, pch=4, col="black", cex.main=0.8, 
     main= "(a) Sample in database")
plot(xy, add=TRUE, main="search area")
legend("center",legend =c("Search area"), cex=0.8, bty="n")

#Search within an existing database
Data = soil[,c("pH")]
aoi_extent=data.frame(lons=c(36.935,36.935,38.4,38.4,36.935),
               lats=c(-2.52,-1.52,-1.52,-2.52,-2.52))
Index=DataAvailabilityIndex(aoi_extent, 20, CrS, Data)
plot(soil, col=NA, cex.main=0.8, main="(b) Data availability")
plot(Index, asp=0.5, add=T)
legend("center",legend=c("Density of points"),
       cex=0.8 ,bty="n")
Example application of data search tool

Figure 3.2: Example application of data search tool

3.4 Accuracy and uncertainty assessment

Accuracy and uncertainty are statistical approaches for evaluating the quality of soil assessments. Accuracy quantifies the closeness of estimates to the measured/true values while uncertainty quantifies the occurrence or probability of estimates within expected range around the true value at some level of confidence (Piikki et al., 2021). Accuracy and uncertainties target errors in soil assessment and are quantified by use of either statistical indices or graphical/map illustrations. Popularly used indices for accuracy assessment are bias (or mean error-ME), root mean square error (RMSE), correlation (r2), Nash-Sutcliffe coefficient of efficiency (NSE), coefficient of agreement, kappa, tau, etc. The guideline for using these indices are as follows:

The soilassessment contains the function predAccuray which can be used to estimate accuracy indices such as bias, RMSE, r2, and NSE. The function requires a vector of observed and modeled or estimated values as shown in the following code example:

predAccuracy((fitted(ec.m))^2,soilp$ECse)$NSE
#> [1] 0.6529102
predAccuracy((fitted(ec.m))^2,soilp$ECse)$Rsquared
#> [1] 0.6645914

Uncertainty evaluation of soil assessment models is done using indices such as prediction width or interval, variance or standard deviation, confidence interval, error bars, etc. Uncertainty may be due to inherent input data spread or noise (also known as aleatoric uncertainty) or due to modelling inadequacies (epistemic uncertainty). There are many approaches in the literature for evaluating these uncertainties. The soilassessment package uses the bootstrap approach where assessment model is repeated many times and a prediction width estimated from the outputs at certain level of confidence. The larger the prediction width the more uncertain the model is. The soilassessment package contains the function predUncertain for developing spatial uncertainty of models for salt indicators. The function requires the following inputs: spatial data frame of the target indicator to model, stack of spatial predictors, number of repetitions, the level of confidence, and prediction model. Although a higher number of repetitions produces better results, the processing time may be longer for a high number for repetitions. The processing time is also influenced by the computing power and size of the data. The following example illustrates how to develop modelling uncertainty for spatial prediction of ECse:

soilec1  =soil2[,c("ECse")]
pred_uncertc=predUncertain(soilec1,predictors,4,95,"rf")
spplot(pred_uncertc, "pred_width", 
       scales = list(draw = TRUE),
       sp.layout = list(list("sp.points", soilec1, pch = 3,
                             cex=0.4, col="green")),
       legend=list())
ECse (dS/m) prediction width at 95% confidence interval

Figure 3.3: ECse (dS/m) prediction width at 95% confidence interval

plot((fitted(ec.m))^2~soilp$ECse, 
     xlim=c(min(soilp$ECse),max(soilp$ECse)), 
     ylim=c(min(soilp$ECse),max(soilp$ECse)), 
     xlab="Harmonized EC (dS/m)",
     ylab="Modelled EC (dS/m)", 
     cex=0.8,cex.lab=0.8,cex.axis=0.75)
abline(a=0,b=1,lty=20, col="blue")
Accuracy assessment of ECse prediction

Figure 3.4: Accuracy assessment of ECse prediction

The output of uncertainty assessment is a spatial distribution of model prediction width at the chosen level of confidence (Figure 3.3). Comparison of the spatial distribution of salt levels (Figure 2.8), uncertainty (Figure 3.3) and accuracy assessments (Figure 3.4) show that high EC were not properly modeled and may be used with caution. In general combined application of uncertainty and accuracy evaluation can be used in soil health assessment to:

The data search function in the soilassessment package can also be used on the global database to identify:

  1. availability of soil indicators for soil health assessment at various levels such as global, regional, national, etc.
  2. areas with gaps in global data availability and target such areas with campaign to improve the global data
  3. availability of other data and their harmonization needs for use in soil health assessment
# Search boundary for Zimbabwe in global data 
x <- c(24.99,24.99,32.83,32.83,24.99)
y <- c(-22.03,-15.05,-15.05,-22.03,-22.03)
yx=data.frame(cbind(x, y))
CRs="+proj=longlat +datum=WGS84 +no_defs"
Data1=SASglobeData("ec2.5","ZWE")
Data=SASglobeData("ecse","ZWE")
coordinates(Data1)=~Longitude+Latitude
coordinates(Data)=~Longitude+Latitude
crs(Data)=CRs
crs(Data1)=CRs
Index1=DataAvailabilityIndex(yx,40,CRs,Data1)
Index=DataAvailabilityIndex(yx,40,CRs,Data)
rasterVis::levelplot(stack(Index, Index1), 
                     names.attr=c("ECse data","EC(1:2.5) data"))
Availability of EC Zimbabwe data in global soil database

Figure 3.5: Availability of EC Zimbabwe data in global soil database

The global soil data for assessing salt levels has many data gap challenges which can influence the spatial information generated from the data. The data search facilities in the soilassessment package can support identification of these gaps and improve development of global information on salt levels in the soil. The following example shows how complementary use of soil data search and harmonization model information can facilitate data preparation for the development of appropriate information on salt levels in the soil.

The data search output in Figure 3.5 shows that there were more locations with non-standard EC data (EC in 1:2.5 solution) than the locations with ECse data for Zimbabwe in the global database. If non-standard EC were omitted when developing spatial distribution of EC, there would be more gaps and uncertainty than if the non-standard data were harmonized and included in the analysis. Examples where non-standard data have been expunged from the analysis can be found in the literature especially when developing of large-area maps of salt indicators (Hassani et al., 2020; Ivushkin et al., 2019; Wicke et al., 2011). Such approaches can benefit from the data search and harmonization functions in the soilassessment package and improve their maps.

References

Abrol, I.P., Yadav, J.S.P., Massoud, F.I., 1988. Salt-Affected Soils and their Management, FAO SOILS BULLETIN. FAO.
Artzy, M., Hillel, D., 1988. A defense of the theory of progressive soil salinization in ancient southern Mesopotamia. Geoarchaeology 3, 235–238. https://doi.org/10.1002/gea.3340030306
Asfaw, E., Suryabhagavan, K.V., Argaw, M., 2018. Soil salinity modeling and mapping using remote sensing and GIS: The case of Wonji sugar cane irrigation farm, Ethiopia. Journal of the Saudi Society of Agricultural Sciences 17, 250–258. https://doi.org/10.1016/j.jssas.2016.05.003
Batjes, N.H., Ribeiro, E., Oostrum, A. van, 2020. Standardised soil profile data to support global mapping and modelling (WoSIS snapshot 2019). Earth System Science Data 12, 299–320. https://doi.org/10.5194/essd-12-299-2020
Chhabra, R., 2004. Classification of Salt-Affected Soils. Arid Land Research and Management 19, 61–79. https://doi.org/10.1080/15324980590887344
Daliakopoulos, I.N., Tsanis, I.K., Koutroulis, A., Kourgialas, N.N., Varouchakis, A.E., Karatzas, G.P., Ritsema, C.J., 2016. The threat of soil salinity: A European scale review. Science of The Total Environment 573, 727–739. https://doi.org/10.1016/j.scitotenv.2016.08.177
Dierke, C., Werban, U., 2013. Relationships between gamma-ray data and soil properties at an agricultural test site. Geoderma 199, 90–98. https://doi.org/10.1016/j.geoderma.2012.10.017
Dooremolen, W.A. van, 1992. Monitoring soil salinity using electromagnetic conductivity measurements and geostatistical processing. A case stiudy in Taveta, Kenya (Consultancy {Report} No. 15788). Kenya Soil Survey, Nairobi, Kenya.
FAO, 2006. Guidelines for soil description, 4th ed. ed. Food; Agriculture Organization of the United Nations, Rome.
Greenacre, M., Groenen, P.J.F., Hastie, T., D’Enza, A.I., Markos, A., Tuzhilina, E., 2022. Principal component analysis. Nature Reviews Methods Primers 2, 100. https://doi.org/10.1038/s43586-022-00184-w
Haldar, A., Sahoo, A., Bandyopadhyay, S., Das, K., Gangopadhyay, S., Dwivedi, B., 2021. Comparison of different methods of electrical conductivity determination for assessment of salinity in soils of coastal region, West Bengal. International Journal of Chemical Studies 9, 116–121. https://doi.org/10.22271/chemi.2021.v9.i1c.11453
Hassani, A., Azapagic, A., Shokri, N., 2020. Predicting long-term dynamics of soil salinity and sodicity on a global scale. Proceedings of the National Academy of Sciences 117, 33017–33027. https://doi.org/10.1073/pnas.2013771117
Ivushkin, K., Bartholomeus, H., Bregt, A.K., Pulatov, A., Kempen, B., Sousa, L. de, 2019. Global mapping of soil salinity change. Remote Sensing of Environment 231, 111260. https://doi.org/10.1016/j.rse.2019.111260
Joseph, V.R., 2022. Optimal ratio for data splitting. Statistical Analysis and Data Mining: The ASA Data Science Journal 15, 531–538. https://doi.org/10.1002/sam.11583
Kihara, J., Bolo, P., Kinyua, M., Nyawira, S.S., Sommer, R., 2020. Soil health and ecosystem services: Lessons from sub-Sahara Africa (SSA). Geoderma 370, 114342. https://doi.org/10.1016/j.geoderma.2020.114342
King, W.L., Kaminsky, L.M., Gannett, M., Thompson, G.L., Kao‐Kniffin, J., Bell, T.H., 2022. Soil salinization accelerates microbiome stabilization in iterative selections for plant performance. New Phytologist 234, 2101–2110. https://doi.org/10.1111/nph.17774
Lesch, S.M., Strauss, D.J., Rhoades, J.D., 1995. Spatial Prediction of Soil Salinity Using Electromagnetic Induction Techniques: 2. An Efficient Spatial Sampling Algorithm Suitable for Multiple Linear Regression Model Identification and Estimation. Water Resources Research 31, 387–398. https://doi.org/10.1029/94WR02180
Nguyen, K.-A., Liou, Y.-A., Tran, H.-P., Hoang, P.-P., Nguyen, T.-H., 2020. Soil salinity assessment by using near-infrared channel and Vegetation Soil Salinity Index derived from Landsat 8 OLI data: A case study in the Tra Vinh Province, Mekong Delta, Vietnam. Progress in Earth and Planetary Science 7, 1. https://doi.org/10.1186/s40645-019-0311-0
Omuto, C.T., Scherstjanoi, M., Kader, M.A., Musana, B., Barman, A., Fantappiè, M., Jiménez, L.S., Jimenez, W.A., Figueredo, H., Balta, R., Santander, K., Malatji, A., Nahar, A., Kairat, A., Ahmadzai, H., Morisson, J., Stone, S., Roopnarine, R., Eudoxie, G., Khat, P., Phy, C., Seng, V., Janjirawuttikul, N., Tina, M., Farradas, M., Alferihat, M., Desire, K., Jayeoba, O.J., Loum, M., Ahmad, W., Al Rasbi, A.S., Matolo, N., 2023. Harmonization service and global library of models to support country-driven global information on salt-affected soils. Scientific Reports 13, 13157. https://doi.org/10.1038/s41598-023-40078-9
Omuto, C.T., Vargas Rojas, R., EL Mobarak, A., Nuha, M., Viatkin, K., Yigini, Y., 2020. Mapping of salt-affected soils – Technical manual. FAO. https://doi.org/10.4060/ca9215en
Omuto, C.T., Vargas, R.R., Elmobarak, A.A., Mapeshoane, B.E., Koetlisi, K.A., Ahmadzai, H., Mohamed, N., 2022. Digital soil assessment in support of a soil information system for monitoring salinization and sodification in agricultural areas. Land Degradation & Development 33, 1204–1218. https://doi.org/10.1002/ldr.4211
Piikki, K., Wetterlind, J., Söderström, M., Stenberg, B., 2021. Perspectives on validation in digital soil mapping of continuous attributes—A review. Soil Use and Management 37, 7–21. https://doi.org/10.1111/sum.12694
Pinheiro, J.C., Bates, D.M., 2000. Mixed-Effects Models in Sand S-PLUS, Statistics and Computing. Springer New York, New York, NY. https://doi.org/10.1007/978-1-4419-0318-1
Rengasamy, P., 2006. World salinization with emphasis on Australia. Journal of Experimental Botany 57, 1017–1023. https://doi.org/10.1093/jxb/erj108
Rhoades, J.D., 2018. Salinity: Electrical Conductivity and Total Dissolved Solids, in: Sparks, D.L., Page, A.L., Helmke, P.A., Loeppert, R.H., Soltanpour, P.N., Tabatabai, M.A., Johnston, C.T., Sumner, M.E. (Eds.), SSSA Book Series. Soil Science Society of America, American Society of Agronomy, Madison, WI, USA, pp. 417–435. https://doi.org/10.2136/sssabookser5.3.c14
Rhoades, J.D., Chanduvi, F., Lesch, S.M., 1999. Soil salinity assessment: Methods and interpretation of electrical conductivity measurements, FAO irrigation and drainage paper. Food; Agriculture Organization of the United Nations, Rome.
Richards, L.A., 1954. Diagnosis and Improvement of Saline and Alkali Soils., Agriculture Handbook. USDA, Washington, D.C.
Seo, B.-S., Jeong, Y.-J., Baek, N.-R., Park, H.-J., Yang, H.I., Park, S.-I., Choi, W.-J., 2022. Soil texture affects the conversion factor of electrical conductivity from 1:5 soil-water to saturated paste extracts. Pedosphere 32, 905–915. https://doi.org/10.1016/j.pedsph.2022.06.023
Shahid, S.A., Zaman, M., Heng, L., 2018. Introduction to Soil Salinity, Sodicity and Diagnostics Techniques, in: Guideline for Salinity Assessment, Mitigation and Adaptation Using Nuclear and Related Techniques. Springer International Publishing, Cham, pp. 1–42. https://doi.org/10.1007/978-3-319-96190-3_1
Szabolcs, I., 1989. Salt-affected soils. CRC Press, Boca Raton, Fla.
Van Looy, K., Bouma, J., Herbst, M., Koestel, J., Minasny, B., Mishra, U., Montzka, C., Nemes, A., Pachepsky, Y.A., Padarian, J., Schaap, M.G., Tóth, B., Verhoef, A., Vanderborght, J., Van Der Ploeg, M.J., Weihermüller, L., Zacharias, S., Zhang, Y., Vereecken, H., 2017. Pedotransfer Functions in Earth System Science: Challenges and Perspectives. Reviews of Geophysics 55, 1199–1256. https://doi.org/10.1002/2017RG000581
Wadoux, A.M.J.-C., Minasny, B., McBratney, A.B., 2020. Machine learning for digital soil mapping: Applications, challenges and suggested solutions. Earth-Science Reviews 210, 103359. https://doi.org/10.1016/j.earscirev.2020.103359
Wicke, B., Smeets, E., Dornburg, V., Vashev, B., Gaiser, T., Turkenburg, W., Faaij, A., 2011. The global technical and economic potential of bioenergy from salt-affected soils. Energy & Environmental Science 4, 2669–2681. https://doi.org/10.1039/C1EE01029H