Introduction

Groundwater is frequently the sole stable supply of freshwater resources and the only sustainable source of water, particularly in arid and semiarid environments (Adimalla et al. 2020; Wu et al. 2020). So, groundwater aquifers have become an important supply of water for the sustenance of ecosystems in these regions (Subba Rao 2018). Water resources, particularly those utilized for agriculture, are in limited supply in arid and semi-arid environments such as the Kingdom of Saudi Arabia. In recent years, water management measures have been established in these communities, which are mostly dependent on groundwater and regular runoff. Sustainable groundwater development is challenged not only by a lack of resources but also by quality degradation (Morris et al. 2020). Consequently, groundwater sustainability is a national aim for Saudi Arabia, as the agricultural sector relies on groundwater aquifers as a key source of irrigation, particularly under certain situations.

Several studies have indicated that certain factors, including evaporation, rock weathering, mineral dissolving, ion exchange, and seawater intrusion, have an impact on the quality of coastal groundwater zones (Li et al. 2019; Masindi and Abiye 2018; Chidambaram et al. 2018). The irrigation water quality has a significant influence on salinization of soil, productivity, agricultural production, and health risk (Prakash et al. 2020). As a result, water quality for irrigation constantly comprises varying quantities of dissolved elements (Jarvie et al. 1998) resulting from both natural (rainfall, weathering, and rock and soil breakdown) and human activities (residential and commercial).

According to the investigations, the quality of groundwater has deteriorated mostly as a result of sodium danger, high salt content, and nitrate pollution (Al-Hadithi 2012; Phadatare et al. 2016). Higher sodium concentrations in groundwater have been reported to hinder plant development through lowering porosity and permeability in clay-dominated soils (Zahedi 2017; Abbasnia et al. 2019; Gharibi et al. 2019). High salt concentration inhibits water conveyance, whereas a lack of salt lowers soil penetration. According to studies, nitrate pollution in groundwater is a worldwide concern as a result of a high supply of synthetic fertilizers, aquaculture wastes, sewage disposal, and animal wastes (Suther et al. 2009). As a result, the agricultural water quality must be examined in order to mitigate negative effects on irrigation (Mohammed 2011).

Numerous studies have been conducted to monitor and evaluate water quality for agricultural utilizing individual physical and chemical parameters and multiple irrigation water quality indices (IWQIs) (Meireles 2010; Xing et al. 2018; Zahedi 2017; Abbasnia et al. 2019; Gharibi et al. 2019). Therefore, IWQIs may be assessed using a simple mathematical procedure that turns enormous amounts of water characteristics into a single number representing the cumulative effect of total water quality values (Saeedi et al. 2010).

Furthermore, many engineering mathematical models and diagrams that are typically employed in hydrochemistry evaluations are costly, inefficient in terms of time, and need a huge number of responses and model assumptions. All of these constraints limit the accuracy of predictions to regional or lower sizes (Abd-Elrahman et al. 2014; Krishna Kumar et al. 2015). Because existing techniques of monitoring and regulating the quality of water in actual time and on a large scale are limited, there is an essential need for precise, realistic, rapid, and low-cost measurement methods. These methodologies enable decision-makers to establish critical groundwater quality indicators in a methodical manner. IWQIs such as irrigation water quality index (IWQI), total dissolved solids (TDS), sodium adsorption ratio (SAR), potential salinity (PS), magnesium hazard (MH), and residual sodium carbonate (RSC) are widely used for categorizing the irrigation schemes suitability of groundwater samples, which aids in determining the infiltration rate of aquifers (Khan et al. 2020; Aravinthasamy et al. 2020). Horton (1965) created the first water quality index (WQI) approach to combine many water-related factors into a single value that could be used to reflect overall water quality. Many scholars have created various water quality indices to assess the appropriateness of groundwater and surface water for irrigation, industrial usage, and biodiversity (Abbasnia et al. 2019; Gad et al. 2021; Khadr et al. 2021). One of the most significant drawbacks of this qualitative assessment approach is that it necessitates expert knowledge in the allocation of variable weights in order to calculate the water quality index score, implying that the true outcome is ambiguous. The IWQI is calculated by converting several values from physicochemical element data into a single value that reflects the water quality level's suitability for irrigation. To solve this challenge, PLSR models have been used in this study. Several researchers have investigated ways to lessen the subjectivity of the classic water quality index approach, which has shown to be a more exact and valuable tool for accurate weighing systems, by giving entropy-based weights to significant ions (He and Wu 2019). On the other hand, groundwater quality research entails large-scale data collecting and laboratory analysis, as well as testing and data management (Tiyasha et al. 2020). Meanwhile, due to the subjectivity of WQI's computation, there are inconsistencies in its interpretation of the results. As the prior research has shown, there is no perfect or universal WQI model. As a result, implementing a viable and cost-effective approach for reliable water quality evaluation is critical.

In order to solve this challenge, PLSR methods were used in this study. To calculate the IWQIS, the PLSR approach could be used to identify the most effective parameters. As a result, the number of components used in the chemical analysis to establish WQIs is reduced, as is the cost. A prominent strategy to represent a linear connection among huge independent and dependent parameters is the PLSR approach (Abowaly et al. 2021; El Osta et al. 2022). Many collinear components can be reduced to a few non-correlated latent variables using PLSR, reducing duplicate data and limiting overfitting and underfitting (Gad et al. 2020; Elsayed et al. 2021). Because of the benefits of these approaches, the WQIs may be calculated in real-time from a large amount of data.

Therefore, this study was undertaken to (1) identify groundwater chemistry, groundwater types and their geochemical controlling processes using physicochemical parameters and imitative techniques; (2) assess groundwater suitability for agriculture purposes using several IWQIs; and (3) evaluate the efficacy of PLSR models as quick approaches for predicting the six IWQIs of the groundwater.

In order to ensure successful management, this research intends to give tools for improved groundwater assessment judgments, aid in the detection of pollution sources, and provide a clearer picture for the redesign of sampling tactics by concentrating on the most useful water quality metrics.

Sites description

The Makkah Al-Mukarramah region has an area of about 141,216 km2 with a number of major watersheds (about 44 coastal Wadies) characterized by heavy flashfloods and groundwater resources (Fig. 1a). This study focused on two Wadies of the Makkah Al-Mukarramah region in order to take into account the different groundwater conditions. The first Wadi is called Qanunah and is located in the southwestern region of the Al Qunfudhah Governorate, which is one of the most important watersheds in Makkah Al-Mukarramah Province (Fig. 1b). This Wadi crossing several towns and villages by a total length of about 108 km begins from the high mountains of the Hijaz west heading in the flow downward toward the Red Sea passing through Al Qunfudhah City. It is situated between longitudes 41° 05′ and 41° 55′ E and latitudes 19° 05′ and 19° 50′ N, extending from the northeast to southwest with a total area of about 2393.7 km2 (Fig. 1b). Recently Wadi Qanunah got more attention due to the experienced heavy flashfloods and groundwater resources development plans. The second catchment area is Wadi Marawani, which is located northeast of Jeddah City by about 90 km, between longitudinal 39° 5′ and 40° 15′ E and latitudinal 21° 50′ and 22° 55′ N (Fig. 1c). This basin is prone to flooding and has abundant groundwater resources.

Fig. 1
figure 1

Location maps of the investigated areas and measuring points: a Map of Makkah Al-Mukarramah Province, Saudi Arabia, and location of groundwater wells and water samples in Wadi Qanunah b and Wadi Marawani c

These Wadies receive a relatively good amount of rainfall, which is highly variable in terms of spatial and frequency. Rainfall generally increases from west to east, based on the maps of rainfall distributions for Wadi Qanunah and Wadi Marawani as shown in Figs. 2a, b, respectively. The average rainfall ranges from 100 mm in the downstream of Wadi Qanunah to 400 mm in the upstream (Fig. 2a). The upper mountainous region of the Wadi Qanunah is responsible for this large variation in rainfall values (Masoud 2016). While the maximum total annual rainfall is 110 mm and minimum, value is 70 mm for Wadi Marawani (Fig. 2b). The hydraulic responses of these Wadies depend on meteorological, geological, and morphological characteristics. Therefore, it is expected that the selected basins will be relatively rich in surface water in the form of floods that resulted after the rains. Accordingly, these different conditions will have a positive impact on the recharge of groundwater in the area and the improvement of groundwater quality.

Fig. 2
figure 2

Annual distribution maps of mean rainfall (mm) in Wadi Qanunah (a) and Wadi Marawani (b), Makkah Al-Mukarramah Province, Saudi Arabia

Geomorphological and geological settings

Topographically, The Makkah Al-Mukarramah Province has a wide range of altitudes varied from zero to 2984 m above sea level (amsl). The Wadi Qanunah basin begins on the high eastern slopes of the escarpment and descends to the west from the Tihama coastal plains near the Red Sea. As shown in Fig. 3a, the height of this basin varied from 0 to 2378 m with a mean elevation of about 586 m (amsl). A land area of 0–200 m (amsl) constitutes approximately 21% of the total study region. This corresponds to the area of sediments deposited in the delta representing the Quaternary and Tertiary periods. In total, 60% of the area has elevations between zero and 650 m (amsl) with sub-basins with low hazard levels, while 40% have elevations from 650 to 2378 m (amsl) with medium to high hazard degrees.

Fig. 3
figure 3

Digital elevation models (DEM): a Wadi Qanunah basin, and b Wadi Marawani basin, Makkah Al-Mukarramah Province, Saudi Arabia

In the mountainous area, Wadi Marawani basin is high 1661 m above mean sea level (amsl), while the Wadi surface is flat with elevation ranging from 1 to 400 m (amsl) as shown in Fig. 3b. The watershed area of Wadi Marawani is about 2347 km2, which extends over a distance of 70 km with a maximum width of about 2 km (Al-Nujaidi 1978). In Wadi Marawani, the stream has an asymmetrical shape and its flow runs from east to west, which is covered by alluvial deposits ranging in grain size from sand to boulders.

Geologically, Wadi Qanunah basin lies within the Arabian Shield in the southwest part of Saudi Arabia (Prinz 1983; Greenwood 1975a, b). This region has experienced long and complex geological structures as well as geomorphological changes over the course of geological time. The lithology sequence in the study basin has extents from Precambrian, Tertiary to Quaternary periods (Fig. 4a). Precambrian rocks are composed of three assemblages of the Baysh group, which are made up of mafic and pyroclastic rocks (Greenwood 1975a, b). Tertiary rocks are found only in the western part of the Wadi and cover only a small area about 2% of its total area. The Quaternary sedimentary layers occupy about 12% of the total area of the Wadi, consisting mainly of gravel, sand, silt, and Sabkha deposits, and cover the coastal plain and the Wadi channels.

Fig. 4
figure 4

Geologic maps: a Wadi Qanunah basin, and b Wadi Marawani basin, Makkah Al-Mukarramah Province, Saudi Arabia

The lithological units that dominated in Wadi Marawani basin in the north of Makkah Al-Mukarramah Province belong to the era that presented by the Precambrian, Tertiary and Quaternary (Fig. 4b). The upstream part of the Wadi is mostly composed of alkali olivine basalt of the Rahat Group (Hammah Formation), with subordinate feldspathoidal lava, little alkalic intermediate lava, and minor pyroclastic rocks. This rock type ranges in age from Paleocene to Miocene era. The Late Proterozoic rock, which is made up of Sericite–chlorite schist of the Samran Group, is representing the oldest rock unit that occurred in the central portion of Wadi Marawani. Moreover, the study area has some outcrops of unaltered post-tectonic plutonic rocks including granite, quartz-diorite, quartz-monzodiorite, syenite, and gabbro. The bottom of Wadi Marawani consists of Quaternary alluvial deposits that are a result of the weathering of the surrounding rock units. Generally, the alluvial deposits are consisting of medium- to coarse-grained gravel along the main channels, and fine-grained sand and clay in the flat areas.

The Quaternary deposits in the two studied Wadies constitute the most important renewable water resource of different conditions, which is used for irrigation, household needs, and drinking water in many areas. The quality of its groundwater is affected at each step from condensation, precipitation, percolation, dissolution of ions from the rocks of the aquifer, and discharge.

Materials and methods

Samples collection and field measurements

During the field-surveying trip in the year of 2021, depths to groundwater levels were measured in 115 groundwater wells in Makkah Al-Mukarramah Province, KSA (53 wells in Wadi Qanunah and 62 wells in Wadi Marawani), using sounder device (GLT500A 30–500 m). In addition, groundwater samples were collected from Wadi Qanunah basin (50 water points) and Wadi Marawani basin (64 water points) to calculate IWQIs for assessing the validity of groundwater resources for agricultural (Fig. 1a, b). To prevent the impact of the environment on the physical properties of the collected samples, temperature (T°), pH, EC, and TDS were determined in situ, using calibrated digital field multi-parameter device (Hanna HI 9033). The collected samples were stored in 1000 mg plastic bottles at 4 °C refrigerator and then were refined by 0.45 µm membrane for the laboratory measurements of major ions.

Laboratory analysis

Thirteen physicochemical parameters were determined in 114 groundwater samples for the two Wadies using conventional analytical procedures (APHA 2012). Volumetric titration methods were applied using EDTA to analyze Ca2+, and Mg2+, while AgNO3 and HCl as a standard to analyze Cl, HCO3˗, and CO3. A flame photometer (AFP 100, Hamburg, Germany) was used to analyze K+ and Na+, while the colorimetric method was applied to analyze SO4 and NO3˗ using a spectrophotometer (UV 1600 PC). The verification of analytical error of analyzed ions concentration in meq/L−1 was crosschecked using charge-balance error (CBE) within the limit ± 5% (Domenico and Schwartz 1998), according to Eq. 1.

$${\text{CBE}} = \frac{{\sum {{\text{Cations}}} - \sum {{\text{Anions}}} }}{{\sum {{\text{Cations}}} + \sum {{\text{Anions}}} }} \times 100$$
(1)

In terms of quality control, the analytical processes were validated by performing adequate device calibration and assessing the accuracy of the analyzed samples.

Indexing approach

Irrigation water quality indices (IWQIs)

The IWQIs including IWQI, TDS, SAR, PS, MH, and RSC were calculated using cited references with respect to physicochemical properties of the groundwater samples, as indicated in Table 1 as follows:

Table 1 The IWQIs, formula, and references

Irrigation water quality index (IWQI)

The IWQI is a non-dimensional measure with a range of 0–100 that was computed in relation to parameters such as EC, SAR, Na+, Cl, and HCO32− (Meireles et al. 2010; Spandana et al. 2013; Abbasnia et al. 2019), as follows the equation:

$${\text{IWQI}} = \mathop \sum \limits_{i = 1}^{n} Q_{i} W_{i}$$
(2)

where Wi is the established weight of each parameter and Qi is the value of quality measurement according to the tolerance limits (Table 2)

$$Q_{i} = Q_{\max } - \left( {\frac{{\left[ {\left( {X_{ij} - X_{{{\text{inf}}}} } \right) \times Q_{{{\text{imap}}}} } \right]}}{{X_{{{\text{amp}}}} }}} \right)$$
(3)

where Xij : The observed value for each parameter, Xinf : The value that corresponds to the lower limit of the class, Qimap : The class amplitude, Xamp : The class amplitude to which the parameter belongs

Table 2 Limiting values for parameters in the computation of quality measurement (Qi)

Lastly, the Wi values were calculated as the following equation:

$$W_{i} = \frac{{\mathop \sum \nolimits_{j = 1}^{k} F_{j} A_{ij} }}{{\mathop \sum \nolimits_{j = 1}^{k} \mathop \sum \nolimits_{i = 1}^{n} F_{j} A_{ij} }}$$
(4)

where F = The auto value of component 1, A = The largely limited of parameter i by factor j, i = The number of physicochemical parameters chosen by the model, ranging from 1 to n, j = The number of factors chosen by the model, ranging from 1 to k ij.

Partial least squares regression model (PLSR)

The PLSR is a method for analyzing multivariate data (Abowaly et al. 2021). It is a good strategy for data processing when there are more input parameters than output parameters, and there is a lot of collinearity and noise in the input variables' data. The PLSR models were created utilizing chemical parameters in Table 1 as input variables and the measured indices (IWQI, TDS, SAR, PS, MH, and RSC) as single response variables (Fig. 5). To link the selected chemical parameters as the input variables to the output variables of six IWQIs, PLSR was used in conjunction with cross-validation using the leave-one-out method (LOOCV). The best ONLFs, which presented the highest R2 and the lowest RMSE, were selected to correctly exemplify the calibration data without over- or underfitting. According to the software program's recommendations, the datasets were subject to random tenfold cross-validation to increase the results' robustness (Unscrambler X software Version 10.2). The following statistical metrics have been used to estimate the behavior of a regression model: coefficient of determination (R2) and root mean square error (RMSE). The following are the explanations for all parameters: Fave is the average value, Fact is the actual value that was quantified from laboratory calculations, Fp is the forecast or simulated value, and N is the total number of data points.

$${\text{RMSE}} = \sqrt {\frac{1}{N}\mathop \sum \limits_{i = 1}^{N} \left( {F_{{\text{ act}}} - F_{ p} } \right)^{2} }$$
(5)
$$R^{2} = \frac{{\sum \left( {F_{{\text{ act}}} - F_{p} } \right)^{2} }}{{\sum \left( {F_{{\text{ act}}} - F_{{\text{ ave}}} } \right)^{2} }}$$
(6)
Fig. 5
figure 5

Schematic diagram of the methodology of PLSR used in this study to predict IWQI, TDS, SAR, PS, MH, and RSC based on the selected chemical parameters

Data analysis and processing

Statistical analyses using SPSS software version 22 (SPSS Inc., Chicago, IL, USA) were applied for physicochemical characteristics and IWQIs. Based on anion and cation compositions, a Piper trilinear diagram (Piper 1944) was applied using groundwater under windows software version 1.30 (GWW) to delineate hydrogeochemical evolution and water types. The Gibbs graph is often utilized to illustrate the link between water chemistry and aquifer metrics features using a Windows Excel Sheet for anions and cations (Gibbs 1970; Vasanthavigar et al. 2012). Spatial distribution of various IWQIs was performed in ArcGIS 10.2 program utilizing the inverse distance weighting (IDW) over the Kriging interpolation method. Cluster analysis (CA) and principal component analysis (PCA) were used (PAST software Version 4.2) to find the effective components in groundwater and to enhance water quality evaluations by summarizing data analysis into recognizable patterns (Rakotondrabe et al. 2018).

Results and discussions

Hydrogeological aspects

According to the information collected from the comprehensive survey of 115 groundwater wells from the selected two Wadies, the water-bearing formation is formed mostly from alluvial deposits (gravel, sand, and silt). The Quaternary aquifer in these two basins occupies the coastal plains and Wadi channels with a maximum thickness of about 74 m in Wadi Qanunah and 118 m in Wadi Marawani. Igneous metamorphic rocks form the bedrock of this aquifer making them an ideal host for groundwater preservation (Sharaf et al. 2004). Therefore, the Quaternary aquifer in the study Wadies is of unconfined condition, shallow, and is directly recharged by occasional rainfall and flooding where most of the precipitation appears as runoff and flows toward the Red Sea.

According to field measurements made on 115 drilled wells, the depth to groundwater ranges from 0.8 to 21.7 m for Wadi Qanunah and from 1 to 110 m below the surface of the ground in Wadi Marawani. Consequently, the water table distribution maps were created to show the groundwater flow along the two Wadies (Fig. 6a, b). According to these maps, the groundwater in Wadi Qanunah basin flows generally from northeast to southwest toward the Red Sea (Fig. 6a). This is in addition to the presence of groundwater flow in the direction of wells with high withdrawals, especially in the central and northern regions of the study area. This is due to the increase in agricultural activities, especially in the central part of the study area, where the area and thickness of the Quaternary aquifer are increasing. Floods from the Qanunah basin constitute a significant source of groundwater recharge and quality improvement (Al-Gadi and Al-Doaan 2020). On the other hand, groundwater levels in Wadi Marawani range between 1100 m in upstream and zero m toward downstream near the coat of Res Sea (Fig. 6b). In general, the groundwater flows in this basin from east to west with local flowing toward wells with high discharge rates, especially in the central part of the Wadi.

Fig. 6
figure 6

Groundwater flow direction maps: a Wadi Qanunah basin and b Wadi Marawani basin, Makkah Al-Mukarramah Province, Saudi Arabia

Physicochemical parameters of groundwater

The physical and chemical properties of groundwater are important in the initial assessment of its quality and suitability for agricultural use, providing a valuable approach for evaluating patterns, defining specific environmental problems, and transferring knowledge on water resources, geochemical processes, and water quality. The following parameters were used to classify the suitability of groundwater for agriculture purposes in the two selected Wadies. Meanwhile, the chemical ions like , pH, EC, TDS, K+, Na+, Mg2+, Ca2+, Cl, SO4, HCO3˗, CO3, and NO3˗ are altering the quality and productivity of the soil. The statistical analysis of physical and chemical metrics for the collected 114-groundwater samples including range, mean, and standard deviation is presented in Table 3.

Table 3 Statistical analysis of the different physicochemical parameters of groundwater samples in Makkah Al-Mukarramah Province, KSA

The obtained results of physicochemical parameters, at 114 groundwater points across Wadi Qanunah and Wadi Marawani basins in Makkah Al-Mukarramah Province, revealed the sequence of ions as the following: Na+ > Ca2+ > Mg2+ > K+, and Cl > SO4 > HCO3˗ > NO3˗ > CO3. The temperature varied from 23 to 31 °C, which was within acceptable limits for irrigation according to FAO 1994 (< 35 °C). The pH values varied from 7.10 to 8.86 that revealed high alkalinity (pH > 6.5), and validity for agricultural based on Ayers and Westcot 1994. The EC results varied between 429 and 28,700 µS/cm, which revealed that 12% of samples from Wadi Qanunah basin and 54% of samples from Wadi Marawani basin were not suitable for irrigation (EC > 3000 µS/cm) except for certain types of plants that tolerate high salinity of water according to FAO 1994 (EC = 3000 µS/cm) due to Wadi Marawani basin close to the Red Sea and high solute dissolution. The Na+ ion is the dominant cation across two Wadies, which varied from 24.10 to 5150.00 mg/L followed by Ca2+, which varied from 11.60 to 2002.00 mg/L. The Na+ content values indicated that all samples from Wadi Qanunah basin and 78% of samples from Wadi Marawani basin were less than 919 mg/L, which are suitable for irrigation according to FAO 1994 (Na+ = 919 mg/L). The excess concentration of Na+ in water is often inappropriate for irrigation, which lead to degradation of soil properties that modifies the structural properties of the soil and causes it to become alkaline (Richards 1954; Singh et al. 2008; Orou et al. 2016). The Ca2+ content values indicated that 98% of samples from Wadi Qanunah basin and 83% of samples from Wadi Marawani basin were below 400 mg/L within acceptable limits for irrigation according to FAO 1994 (Ca2+ = 400 mg/L). The Mg2+ content varied from 9.0 to 710.0 mg/L, which indicated that 82% of samples from Wadi Qanunah basin and 44% of samples from Wadi Marawani basin were less than 60 mg/L and suitable for irrigation according to FAO 1994 (Mg2+ = 60 mg/L). Therefore, high levels of Mg2+ in the soil can lead to low potential yield and nutrient benefits. The K+ concentration ranged between 0.60 and 28.1 mg/L, which indicated that 14% only of samples in Wadi Qanunah basin were less than 2 mg/L and suitable for irrigation according to FAO 1994 (K+ = 2 mg/L). In addition, the Cl ion is the dominant anion across two Wadies, which ranged between 14.70 and 9666.00 mg/L, followed by SO4, which ranged from 19.3 to 2840.00 mg/L. The Cl values indicated that all collected samples were within the acceptable limit for agricultural except 31% only of samples from Wadi Marawani basin were more than 1036 mg/L and not suitable for irrigation according to FAO 1994 (Cl = 1036 mg/L), while the SO4 values indicated that 22% only of samples from Wadi Marawani basin were above 960 mg/L and not suitable for irrigation based on FAO 1994 (SO4 = 960 mg/L). The alkalinity content ranged between 31.0 and 394.0 mg/L, which is within the acceptable limit for irrigation according to FAO 1994 (HCO3˗ = 610 mg/L). The NO3˗ value ranged from 0.78 to 290.70 mg/L, with an average of 41.27 mg/L, which revealed that most samples were more than 10 mg/L and unsuitable for agriculture according to FAO 1994 (NO3˗ = 10 mg/L) due to the excess use of agrochemicals for longer periods and poor flushing.

Groundwater facies and controlling geochemical processes

The hydrochemical analysis is extremely important in determining groundwater quality. The distribution and type of hydrochemical facies can shed light on variations in groundwater quality within and between aquifers (Gad and El Osta 2020; Walton 1970). The analytical results of physicochemical properties are shown on the Piper trilinear graph to get full information on water's hydrogeochemical facies (Liu et al. 2020). The results showed three distinct groups of groundwater facies (Fig. 7a), corresponding to the geological and hydrogeological conditions of water-bearing formation as the following: (2) Na-Cl facies (Wadi Qanunah and Wadi Marawani basins) revealed the last phase of water evolution and seawater intrusion (Wu et al. 2020), and (3) mixed Mg–Cl–SO4 facies (Wadi Qanunah and Wadi Marawani basins) linked to rock-water interaction.

Fig. 7
figure 7

Groundwater facies and their controlling mechanisms along Wadi Qanunah and Wadi Marawani basins: a Piper trilinear diagram and b Gibbs diagram

The Gibbs diagram is widely used to establish a connection between the water constituent and the aquifer formations. Gibb's graphic identifies the fundamental regulatory mechanisms that govern groundwater geochemistry by presenting TDS vs. (Na + K)/(Na + K + Ca) and Cl/(Cl + HCO3). The collected groundwater points were scattered across the evaporation and rock–water dominance areas (Fig. 7b), which are important mechanisms governing groundwater quality and controlling factors. Based on the Gibbs diagram results (Fig. 7b), the bulk of the samples are dominated by evaporation, which demonstrated a considerable increase in Na+, Cl, and TDS (Adimalla et al. 2020). This finding also implies that the influence of evaporation and rock dominance processes has a significant influence on groundwater quality (Bodrud- Doza et al. 2016; Srinivasamoorthy et al. 2008).

According to Chadah's diagram (1999), results (Fig. 8a), the collected groundwater points from Qanunah and Marawani basins were scattered in fields 2 and 3, which reflect a reverse ion exchange process and mixing with saline water, notably in the downstream of the two Wadies. As a consequence, Ca2+ in the groundwater was exchanged by Na+ in the aquifer, resulting in a decrease in Ca2+ content and an increase in Na+ content, indicating that the cation exchange process affected groundwater quality in the investigated areas. Moreover, the findings of the hydrochemical evolution facies diagram (HEF) indicated the dissolution of evaporate from salt marches in sulfate and chloride-rich aquifer materials (Fig. 8b). The majority of samples with mixed content were found to be rich in Na+ and Ca2+ due to the volcaniclastic sequence of clays in the Quaternary aquifer and the volcaniclastic sequence of Wadi Qanunah and Wadi Marawani basins. Clearly, the groundwater samples spread throughout the intrusion area suggested that intrusion is a significant factor in the creation of dissolved solutes for groundwater samples, particularly in the Wadi Marawani basin. Furthermore, evaporation is also the most important mechanism for groundwater and soil salinization in places with shallow groundwater depths (Yechieli and Wood 2002). Brines from evaporate minerals dissolve in the recharge zone of closed basins, increasing groundwater salinity over time. Consequently, over-pumping and a negative water balance in confined basins lead to salt levels rise from the inflow area to the outflow area and converting the hydrochemical facies from Ca–HCO3 to Na–Cl (Monjerezi 2012). Therefore, chemical composition variations in the two Wadies are mostly caused by changes in groundwater flow direction and reactions (Berner and Berner 2012).

Fig. 8
figure 8

Geochemical processes affecting on water quality along Wadi Qanunah and Wadi Marawani basins: a Chadha diagram and b hydrochemical evolution facies diagram (HEF)

Water quality indices for agricultural purposes

To the best of our knowledge, water quality, soil types, and agricultural activities have a role in determining optimal irrigation methods (Gad et al. 2020; Kaka et al. 2011). So, several indices were employed to monitor the water quality appropriate for agriculture including IWQI, TDS, SAR, PS, MH, and RSC in terms of irrigation. These approaches highlight the possible danger of soil salinization as well as the detrimental impacts of irrigation on soils and plants. The statistical analyses of IWQIs data and the suitability of water quality for agriculture were given (Tables 4 and 5).

Table 4 Statistical analysis of the different IWQIs values
Table 5 Classification of the different water quality indices (WQIs)

Irrigation water quality index (IWQI)

The IWQI provides a clear classification of water quality according to its influence on soil and plants (Adimalla, and Taloor 2020; Gad et al. 2020). The IWQI was developed for urban planners to characterize the cumulative influence of five factors on water quality for agriculture, including EC, SAR, Na+, Cl, and HCO3. The calculated results of IWQI across two Wadies ranged from 15.78 to 95.79, which indicated that approximately 31% of samples fall in the no restriction range, implying that salinity tolerance plants should be avoided by taking irrigated soil characteristics, permeability, and soil sodicity hazards (Ayers and Westcot 1994). In terms of leaching processes, around 33% of samples ranged from low to moderate restriction, which may be used for irrigation the moderate salinity tolerant crops and is recommended for medium to high permeability soils. Finally, the majority of samples (about 36%) had irrigation restrictions ranging from high to severe, which may be used to high sensitivity crops for salt water in loose soil with no compacted layers. Because of the influence of saltwater intrusion and rainfall rates across two Wadies, spatial distribution maps of IWQI in studied regions indicated that groundwater wells in Wadi Qanunah were more appropriate for irrigation than Wadi Marawani (Figs. 9a and 10a).

Fig. 9
figure 9

Spatial distribution maps of IWQIs in Wadi Qanunah basin: a IWQI, b TDS, c SAR, d PS, e MH, and f RSC

Fig. 10
figure 10

Spatial distribution maps of IWQIs in Wadi Marawani basin: a IWQI, b TDS, c SAR, d PS, e MH, and f RSC

Total dissolved solids (TDS)

The TDS is often used to assess the salinity of groundwater, which adds in water from both natural and anthropogenic due to weathering, rock–water interaction, household, industrial, and irrigational practices. The obtained TDS values have a wide range varied from 208.30 to 18,171.00 mg/L, with a mean value of 2028.53 mg/L. The TDS results revealed that about 38% of wells have salinity values less than 700 mg/L, especially in Wadi Qanunah, which reflects no restriction for irrigation. While the majority of samples (45%) have salinity content varied from 700 to 3000 mg/L, which mandates slight to moderate restriction for agriculture. On the other hand, about 17% of wells have a salinity content of more than 3000 mg/L especially in Wadi Marawani, rendering it inappropriate for irrigation and having an impact on agricultural productivity, soil percolation capacity, and infiltration rate (Puntamkar et al. 1988) as shown in Figs. 9b and 10b.

Sodium adsorption ratio (SAR)

The SAR compares the percentage of sodium ions in water to calcium and magnesium ions. It may be computed using Richards' (1954) equation, where all ion concentrations are represented in meq/L. SAR is inversely related to the rate of water percolation in soil. The SAR results ranged from 0.75 to 32.52, with a mean value of 4.98, indicating that the majority of groundwater samples for the two Wadies (about 98%) were classified as excellent to good appropriateness for irrigation, while just 2% of samples were classified as quite bad to unsuitable for irrigation especially in Wadi Marawani (Figs. 9c and 10c), where a lower SAR implies greater water infiltration.

Potential salinity (PS)

The potential salinity of groundwater is determined by the content of Cl and half of the SO42− content. It provides a sense of the irrigation water's appropriateness. Based on the results, the PS values varied from 0.68 to 290.22, with a mean value of 26.18, indicating that approximately 15% of samples were classified as excellent to good, while 14% were categorized as good to injurious, and the majority of samples, approximately 71%, were classified as injurious to unacceptable for irrigation (Figs. 9d and 10d).

Magnesium hazard (MH)

The MH index is determined by the amount of alkaline earth (Ca2+ and Mg2+) in water, which maintains the balance condition in agricultural water. Across two Wadies, the MH values varied from 9.46 to 68.87, with an average of 38.70. These values revealed that the majority of samples (89%) were appropriate for irrigation, whereas around 11% of samples were not suitable (Figs. 9e and 10e). Because of the buildup and increase of alkali ions in the soils, Ca2+ and Mg2+ ions can have an impact on plant development, agricultural output, and irrigation water quality (Karunanidhi et al. 2021).

Residual sodium carbonate (RSC)

The RSC is a frequently used index for determining the appropriateness of water quality for agricultural, which computed to determine the dangerous influence of CO32− and HCO3 on water quality (Kaka et al. 2011; Li et al. 2019). The RSC is used to measure the effect of high CO32− content water on soil and crop development. The quantity of carbonate and bicarbonate present in excess of alkaline earth metals influences the appropriateness of water for agriculture. Due to the deposition of sodium carbonate, an excess of RSC sterilizes soils (Joshi et al. 2018). The RSC values varied from − 156.26 to 0.45, with a mean of − 14.77. These findings suggested that all groundwater wells were deemed safe for irrigation (Figs. 9f and 10f). The RSC may surpass because Na+ adsorption in soil contributes in the accumulation of Ca2+ and Mg2+ as a result of an excess of CO32− and HCO3 in water.

Multivariate statistical analysis

The CA and PCA were employed to identify the causes responsible for differences in water quality by combining main factors into vector of features. CA values for physical and chemical parameters showed three types of clustering (Fig. 11a). According to the CA results, the EC and TDS were grouped together in cluster 1, and Na+, SO42−, and Cl were grouped together in cluster II, while pH, K+, Ca2+, Mg2+, HCO32−, CO32−, and NO3 were grouped together in cluster III. Consequently, the high concentrations of Na+ and Ca2+ reflect rock–water interaction, while the high contents of Cl and SO42− revealed saltwater intrusion. The distributions of physicochemical data through CA revealed the second and final phases of water evolution, as a result of the evaporation processes, saltwater intrusions, and water–rock interactions. The results are matching with the water types stated in Piper and Chadha diagrams under the stress of the geochemical processes stated in Gibbs and HEF diagrams.

Fig. 11
figure 11

The CA and PCA for physicochemical parameters of groundwater samples across Wadi Qanunah and Wadi Marawani basins: a CA and b PCA

According to the PCA results for physicochemical features in the groundwater samples, the PC1 explained 58.64% of total variance that prevailed large positive loading of pH, TDS, Na+, Ca2+, Mg2+, K+, Cl, SO42−, and NO3, while PC1 explained 12.72% of the total variance that prevailed loading of CO32− (Fig. 11b). The majority of cations and anions were grouped together in positive-loading combinations except for CO32−, which indicated that the variables have a significant connection. According to PCA results, the occurrence of nine essential components demonstrated the influence of significant ions on groundwater quality in the studied regions. These findings might be explained by evaporation, weathering, saltwater intrusion, and rock–water interaction. Therefore, incorporating physicochemical features in the PCA for groundwater quality evaluation is a useful and versatile technique with exceptional potential and novel insights.

Different IWQIs forecasting using PLSR models for agriculture purposes

The traditional mathematical approaches discussed in this paper can be utilized to make approximations of IWQIs of water samples (Meireles et al. 2010). However, they need several steps to calculate IWQI (Gad et al. 2020; Elsayed et al. 2021; El Osta et al. 2022). Chemometrics can benefit from the multivariate statistical analysis technique known as the PLSR (Wold et al. 2001). It is a practical method for handling data when collinearity and noise levels in the input variable data are high and the number of input variables is significantly more than the number of output variables. PLSR was studied as an alternate approach for predicting IWQIs in this study since it is rapid, simple, and requires few steps to compute, particularly the IWQI. Table 6 shows the R2 and RMSE of the PLSR models' calibration (Cal.) and validation (Val.) datasets for predicting IWQI, TDS, SAR, PS, MH, and RSC based on chemical parameters. On the basis of pooled data from Wadi Qanunah and Wadi Marawani basins (n = 114), the performance of the PLSR models for predicting the six groundwater indices was evaluated. In both models of the Cal. and Val. datasets, the PLSR model produced a more accurate assessment of six IWQIs for based on values of R2 (Table 6) and slope (Figs. 12 and 13). In Cal. datasets, the PLSR model generated strong estimates for six IWQIs with R2 varied from 0.78 to 1.00. As well as, in Val. datasets, the PLSR model generated strong estimates for six IWQIs with R2 varied from 0.72 to 1.00. The RMSE values for six IWQIs as arranged in Table 6 were 9.02, 269.52, 1.44, 0.63, 5.50, and 0.00 in the Val. Dataset. Figures 12 and 13 show the association of six IWQIs in a 1:1 scatter plot using PLSR for the Cal. and Val. models. In addition, these figures presented a good slope of the linear relationship between measured and predicted for each parameter, the highest slope (1.00) value was showed with RSC, and the lowest slope value (0.63) was showed with MH. The PCs varied from 1 to 6 and were specified for supporting the calibration data without over-fitting for the PLSR models of six WQIS (Table 6). There was no overfitting or underfitting among the measuring, calibrating, and validating datasets for the PLSR models of six IWQIs. Therefore, the accuracy of the models applied in this study is satisfactory and has a good performance for predicting IWQIs in the two Wadies. Like this study’s forecast of WQIs, El Osta et al. (2022) found that PLSR models could be used to forecast five IWQIs and drinking water quality index with R2 varied from 0.85 and 1.00 in the Cal. and Val. for groundwater in Wadi Fatimah, Makkah Al-Mukarramah Province, Saudi Arabia. In the Northern Nile Delta of Egypt, Elsayed et al. (2020) discovered that the PCR and SVMR presented well forecasting the IWQIs R2 value reach up 0.99. Once again, PLSR models based upon numerous chemical parameters could be used to quantify WQIs in water quality evaluations as a unified method.

Table 6 Calibration and validation models results of PLSR for the association between measured and predicted for IWQI, TDS, SAR, PS, MH, and RSC across pooled data
Fig. 12
figure 12

Results of the comparison between measured, calibrated, and validated datasets for IWQI, TDS, and SAR

Fig. 13
figure 13

Results of the comparison between measured, calibrated, and validated datasets for PS, MH, and RSC

Conclusions

This research investigates the appropriateness of Quaternary groundwater aquifer in Wadi Qanunah and Wadi Marawani basins, Makkah Al-Mukarramah Province, Saudi Arabia, for agriculture purposes. Physical and chemical properties, irrigation water quality indices, supported with multivariate modeling (PLSR) and GIS techniques were conducted to identify groundwater hydrogeochemical types and their controlling mechanisms. The obtained physicochemical parameters revealed that ionic sequences of Na+ > Ca2+ > Mg2+ > K+, and Cl > SO4 > HCO3˗ > NO3˗ > CO3 associated with Ca–HCO3, Na–Cl, and mixed Ca–Mg–Cl–SO4 water types. The hydrogeochemical facies of groundwater revealed the influences of evaporation, saltwater intrusion, and reverse ion exchange processes on the groundwater quality. Comprehensive assessments of groundwater quality for irrigation systems were conducted using IWQIs. For example, the IWQI values across studied regions indicated that about 31% of samples were categorized as no restriction range, which preventing salinity tolerance crops, while approximately 33% of samples ranged from low to moderate restriction, and about 36% of samples ranged from high to severe restriction for irrigation, which may be used for irrigating the moderately to high salt sensitivity crops in loose soil with no compacted layers. The PLSR models performed well to estimate the six IWQIs with the highest R2 and slope value, and the lowest RMSE value. Overall, the results revealed that using a proposed PLSR model to estimate groundwater quality fluctuation is mainly reasonable. In other words, the applied PLSR is capable of properly detecting the relevance of input characteristics for forecasting groundwater quality. Therefore, the integration of physicochemical parameters, irrigation water quality indices (IWQIs), multivariate modeling, and GIS approaches are effective and give us a clear picture for assessing groundwater suitability for irrigation and their controlling factors. The technique suggested in this work, which combines physicochemical measurements, IWQIs, and PLSR models, might be further investigated to increase its reliability for surface water under different conditions.