1 Introduction

Soil is a crucial component of the terrestrial ecosystem, providing nutrients for the growth and development of plants (Wang et al. 2018b). Soil organic carbon (SOC), total nitrogen (TN), and total phosphorus (TP) are usually regarded the most critical soil nutrients and play an important role in adjusting soil fertility and biomass production (Elser et al. 2010; Wang et al. 2014). Soil nitrogen (N) and SOC are mainly derived from plant residues and litter, and soil phosphorus (P) is mostly sourced from the weathering of primary rock mineral (Wan et al. 2021), and they are tightly related to each other through a stable proportion in soil and organism (Fang et al. 2019; Liu et al. 2021b). SOC is a key indicator of soil fertility, which influence the structure, function and productivity of ecosystem (Liu et al. 2021a). Furthermore, SOC is the largest carbon pool in terrestrial ecosystem, and its decomposition and sequestration can obviously affect the atmospheric greenhouse gas (CO2) dynamic (Scharlemann et al. 2014). TN and TP also represent essential parts in building soil fertility, and deficiency of them will affect the yield and quality of crops, while excessive TN and TP may do harm to the environment (Gao et al. 2019; Liu et al. 2015). For example, soil N and P entering surface water or groundwater through leaching or runoff will cause non-point source pollution (Wang et al. 2009). Therefore, a comprehensive knowledge of the shifts and driving factors of SOC, TN, and TP contents is significant for accurately evaluating the soil fertility status and protecting the environment.

Numerous studies have revealed that the nutrient dynamics of surface soil are affected by many environmental factors such as anthropogenic activities, topography, climate, and soil properties, with strong spatial variability (Gao et al. 2014; Liu et al. 2021a). Cropping systems may be the primary anthropogenic influence factor that control soil nutrient dynamics. Under different cropping systems, distinct crop covers and agricultural management practices can lead to vast differences in SOC, TN, and TP contents(Wang et al. 2012). For example, Han et al. (2020) found that crop residues under rice and maize monocultures significantly changed the microbial community and increased the contents of SOC, mineralized N and available P in topsoil (0-20 cm). Meanwhile, Zhang et al. (2022) noted that compared with rice-maize rotation systems, rice monoculture favored the soil nutrient contents due to the lower decomposition rate and nutrient loss. Topographic factors (i.e., slope, aspect, and topographic wetness index [TWI]) can modify vegetation cover and local microclimate by regulating the distribution of hydrothermal resources, thus affecting the dynamics of SOC, TN, and TP (Zhang et al. 2015; Hu et al. 2021; Li et al. 2021). Studies showed that aspect is associated with solar radiation, and higher SOC and TN are generally found on shady northern aspect rather than southern aspect (Bangroo et al. 2017). TWI is an important indicator of soil wetness (Hu et al. 2021). Studies reported that high TWI value indicates high soil water content, which is conducive to the accumulation of SOC and TN (Liu et al. 2020; Hu et al. 2021). Slope mainly affects the degree of soil erosion to change the SOC level (Wei et al. 2010). Climate variables, including mean annual temperature (MAT) and mean annual precipitation (MAP), are usually related to plant growth and litter decomposition, and have a great influence on soil nutrient cycling process (Li et al. 2018; Tan et al. 2021). Soil pH regulates nutrient status by controlling microbial activity, and too high or too low pH values have a negative effect on the decomposition of soil organic matter (Penn and Camberato 2019; Wan et al. 2021). However, most of these studies are based on linear relationships, and quantitative assessment of the relative importance of environmental variables based on non-linear relationships is insufficient.

Random forest (RF) is an advanced machine learning algorithm that is commonly applied in various fields as its good predictive performance and importance ranking of variables (Ishwaran and Lu 2019; Jin et al. 2020). Compared with traditional data analysis methods, RF can handle both linear and nonlinear relationships between variables, providing the possibility of more accurate estimation of prediction results (Blyth 1994; Yang et al. 2016; Zeraatpisheh et al. 2019). However, the weak interpretation of its black-box operational model hinders further research (Apley and Zhu 2020). To address this shortcoming, partial dependency plots (PDP) were introduced by Friedman (2001) to visualize the impact of predictors, which is a popular approach for improving the explanatory power of machine learning models (Apley and Zhu 2020). Unlike traditional correlation analysis, PDP takes into account the non-linear relationship between variables, and it specifically shows how the model's predictions are influenced by one or two variables (Friedman 2001; Inglis et al. 2022). For instance, Berk and Bleich. (2013) combined RF with PDP technology to predict the crime risk and provide useful information for judicial decision-making. Based on the boosted regression trees model, Elith et al. (2008) used PDP model to illustrate how different environmental factors affect the distribution of freshwater eels in New Zealand. Although there are numerous studies (Friedman 2001; Elith et al. 2008; Berk and Bleich 2013; Yang et al. 2016) have been conducted to explore the applications of RF and PDP in various fields, few researches use RF and the associated PDP to study the relationship between soil nutrients and environmental factors.

The influencing factors of soil nutrients vary greatly in different regions, and previous studies have mainly focused on the northwest arid region, while few on the southwest part of China (Liu et al. 2017; Yu et al. 2020b). The “Three Gorges Reservoir” (TRG) area accompanied by serious soil erosion is one of the most fragile ecological zones in southwest China (Teng et al. 2017). The reservoir area is characterized by complex topography, with hills and mountains interspersed, which provides an excellent condition to study the influence of environmental factors on soil nutrients (Wang et al. 2018a; Sun et al. 2021). The typical cropping systems in the region are rice monoculture and maize monoculture, which also exist across southwest China. Rice and maize are two major food crops, understanding their soil nutrient status is important for maintaining national food security (Lu et al. 2015).

Therefore, the specific objectives of this study are to (1) reveal the contents and spatial distribution characteristics of SOC, TN, and TP under rice and maize cropping systems (2) identify the main environmental variables and their relative importance related to soil nutrients distribution by the random forest (RF) model; and (3) visualize the specific effects of environmental variables on soil nutrient variation by partial dependence plots (PDP). Information obtained from this study can provide a theoretical basis for optimizing agricultural activities in the southwest China.

2 Materials and methods

2.1 Study area

The study area is located in the northeast of the Three Gorges Reservoir area (30°49′-31°41′N, 107°55′-108°54′E), which is in the Kaizhou County, Chongqing, Southwest China (Fig. 1). The elevation ranges from 118 to 1214 m, with the terrain being high in the northeast and low in the southwest. The climate of this area is subtropical monsoon humid climate with an average annual temperature of 17 °C and annual average precipitation of 1244 mm. Predominant soil types in the area are Luvisols and Cambisols (IUSS Working Group WRB 2006). The main strata are Jurassic system Shaximiao formation (J2s), Jurassic system Suining formation (J3p), Jurassic system Penglaizhen formation (J3sn), and Jurassic system Ziliujing formation (J1-2z). Soil samples were collected in the south of the study area, where the cropping systems are rice monoculture and maize monoculture with over 10 years of planting. The soil testing and formulated fertilization technology was adopted in the study area. The fertilizer was recommended based on the grade of the cultivated land quality and target yield. In the study area, the average cultivated land quality grade is 3–5, and the target yields of rice and maize are about 7273–8333 kg/ha and 6060–7273 kg/ha, respectively. So the N:P2O5 of 16:12 was recommended for rice monoculture and of 18:12 for maize monoculture.

Fig. 1
figure 1

Location of the study area and the distribution of sampling sites

2.2 Soil sampling and chemical analysis

In 2016, a total of 142 soil samples (0–20 cm) were collected after crop harvest (Fig. 1). Among them, 74 soil samples were from paddy fields and 68 soil samples were from dry land. At each site, five subsamples were randomly collected within a 10-m radius, and then they were mixed to form a representative sample (Zhang et al. 2018). The spatial location information (longitude and latitude) of each sampling site was registered with Global Positioning System (GPS MAP 76, Garmin Ltd, USA).

All samples were air-dried and passed through a 2-mm soil sieve in the laboratory. After removing stones and litter, they were stored in polyethylene plastic bottles for further analysis. Soil pH was measured in a soil to water of 1:2.5 with pH meter (Bao 2000). SOC content was measured by potassium dichromate oxidation method (Nelson and Sommers 1983). TN content was determined using the Kjeldahl acid-digestion method (Gallaher et al. 1976). TP content was measured by a colorimetric method with an alkaline oxidation-digestion procedure (Bao 2000).

2.3 Environmental variables

The environmental variables are composed of classification variables (cropping systems, stratum) and numerical variables (soil property, topography and climate), which were selected based on Jenny's model of soil formation factors (Jenny 1994). The cropping systems were introduced to represent the human factor (Haileslassie et al. 2005). Stratum and cropping systems were recorded during sampling. Soil texture were acquired from the dataset named “soil particle-size distribution in China” (Shangguan et al. 2012). Topographic factors, such as elevation, slope, aspect, topographic wetness index (TWI), and valley depth, were calculated with SAGAGIS 7.2.0 by a 30-m × 30-m grid digital elevation model (DEM), which was obtained from NASA Shuttle Radar Topography Mission (SRTM) 1 Arc-Second Global (https://www.usgs.gov/). The climate data including mean annual precipitation and mean annual temperature (30 years, from 1970 to 2000) were downloaded from the WorldClim Database (https://www.worldclim.org), and the resolution of it is 1 km. The TWI was defined as (Moore et al. 1991):

$$\mathrm{TWI}=\mathrm{ln}( \frac{M}{\mathrm{tan}\alpha } )$$
(1)

where M and α are the cumulative upslope area draining through a point and the slope angle at the point, respectively.

2.4 Data analysis

2.4.1 Statistical analysis

Descriptive statistical analysis (i.e., mean, max, min, and coefficient of variation [CV]) was performed to describe the characteristics of SOC, TN, and TP. Before data analysis, the homogeneity of variance was tested by Levene’s test, and the normality of data was checked by Kolmogorov–Smirnov test. One-way analysis of variance (ANOVA) with Tukey’s post hoc test (p < 0.05) was performed to analyze the effects of stratum, and independent t-test was used to detect the differences in soil nutrient contents under different cropping systems. Spearman correlation analysis and redundancy analysis (RDA) were adopted to examine correlations among soil nutrients and environmental factors.

2.4.2 Semivariogram analysis

The spatial dependence of SOC, TN, and TP were evaluated by semivariogram with GS + 9.0 (Gamma Designs Software, Plainville, MI, USA). The semivariogram describes the spatial variability of factors by three major parameters (i.e., nugget value [C0], sill value [C0 + C], and range [A0]) (Duan et al. 2020). C0 and C represent the variation explained by random factors and structural factors, respectively. C0/(C0 + C) represents the strength of spatial autocorrelation for factors. A0 describes the maximum distance of spatial autocorrelation, and when beyond the range the variables have no spatial autocorrelation (Okin et al. 2008). The variable has strong or weak spatial dependency when C0/(C0 + C) is < 0.25 or > 0.75, respectively, otherwise, the variable has moderate spatial dependency (Duan et al. 2020).

2.4.3 Random forest and partial dependence plot

Random forest (RF) model was conducted to determine the relative importance of environmental factors. RF was developed as an extension of the classification and regression tree, which is an advanced machine learning method (Breiman 2001). As RF can prevent overfitting and simplify operation, it has been widely adopted to predict soil properties and identify factors importance (Wiesmeier et al. 2011; Zhang et al. 2021). Partial dependence plots (PDPs) were implemented to visualize the pattern of influence of individual environmental variables on soil nutrient changes. It is an important visualization tool of machine learning models, which can reveal the linear and nonlinear relationship between variables and improve the explanatory power of machine learning models (Friedman 2001; Apley and Zhu 2020). For RF model, 80% samples were randomly selected as training sets and 20% as verification sets in this research. RF model performance is assessed by three widely used accuracy indices, mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination (R2) (Wang et al. 2018c). MAE and RMSE estimate the accuracy and stability of the models, and R2 measures the strength of the linear relationship between observed and predicted values. The three accuracy indices were defined as:

$$\text{MAE = }\frac{1}{{\text{n}}}{\sum }_{\text{j=1}}^{\text{n}}\left|{\text{Q}}_{\text{j}}-{\text{P}}_{\text{j}}\right|$$
(2)
$$\text{RMSE}=\sqrt{\frac{1}{{\text{n}}}{\sum }_{\text{j}=1}^{\text{n}}({\text{Q}}_{\text{j}}-{\text{P}}_{\text{j}})^{2}}$$
(3)
$${\text{R}}^{2} = 1-\frac{{\sum }_{\text{j}=1}^{\text{n}}{(}{\text{Q}}_{\text{j}}-{\text{P}}_{\text{j}}{)}^{2}}{{\sum }_{\text{j}=1}^{\text{n}}{(}{\text{Q}}_{\text{j}}-\overline{\text{Q}}{)}^{2}}$$
(4)

where \({Q}_{j}\) and \({P}_{j}\) are the observed and predicted values of the jth soil sample, respectively. \(\overline{Q }\) and n are the mean value of the measurements and the samples number, respectively.

Basic descriptive statistics and data analysis were conducted using SPSS 25.0 software. Environmental variables were extracted using Sagagis7.2.0. RDA was processed in Canoco 5. RF and PDP were implemented in PyCharm 3.6.8. The spatial variation of soil nutrients was analyzed in GS + 9.0. Figures were plotted with Origin 8.5 software.

3 Results

3.1 Characteristics of soil nutrients

Table 1 presents the basic statistics of soil nutrients. In the whole study area, the overall mean contents of SOC, TN, and TP in topsoil were 9.83 g/kg (range 2.10–25.00 g/kg), 1.12 g/kg (range 0.30–2.99 g/kg), and 0.70 g/kg (range 0.29–1.85 g/kg), respectively. The coefficients of variation (CV) of soil nutrient contents decreased in the order of SOC (45.75%) > TN (41.93%) > TP (36.42%). All of them showed moderate variation (CV = 25–75%).

Table 1 Summary statistics of topsoil soil organic carbon (SOC, g/kg), total nitrogen (TN, g/kg), and total phosphorus (TP, g/kg) contents in the study area

Under rice monoculture, the average contents of SOC and TN were 11.92 g/kg (range 4.70–25.00 g/kg) and 1.36 g/kg (range 0.72–2.99 g/kg), respectively, which were higher than that under maize monoculture (SOC = 7.55 g/kg and TN = 0.87 g/kg) (Table 1). The mean content of TP was 0.59 g/kg under rice monoculture, which was lower than that under maize monoculture (TP = 0.82 g/kg) (Table 1). The CVs of SOC, TN, and TP were smaller under rice monoculture than under maize monoculture (Table 1), indicating that they were more stable under rice monoculture than under maize monoculture.

3.2 Spatial variations in soil SOC, TN, and TP contents

The semivariogram analyses (Fig. 2) reveal the spatial autocorrelation of SOC and TN contents were weak (Co/[Co + C] > 75%), which indicated that their spatial variability was mainly caused by random factors (e.g. cropping systems, fertilization). The spatial autocorrelation was strong (Co/[Co + C] < 25%) for TP content, showing that its spatial variability mainly came from and structural factors (e.g., soil properties, topography). The spatial autocorrelation ranges of SOC and TN (32,409 m) were greatly larger than that of TP (190 m), implying that the distribution of SOC and TN was more homogeneous than TP in the study area.

Fig. 2
figure 2

Semivariograms of soil organic carbon (SOC) (a), total nitrogen (TN) (b), and total phosphorus (TP) (c) contents

3.3 Relationships among nutrient contents and environmental factors

The one-way ANOVA presents that there was no significant difference in soil nutrient contents among different stratum (Fig. S1), which may be due to sampling on the topsoil of cultivated land (Wang et al. 2019), while independent t-test shows that cropping systems had significant influence on SOC, TN and TP contents (Fig. 3). Compared with the cropping system of maize, rice monoculture had higher contents of SOC and TN, but comparatively lower TP content (Fig. 3). Table 2 shows the spearman correlation coefficients for soil nutrient contents and environmental factors. SOC, TN, TP were found to be significantly correlated with sand, clay and soil pH (p < 0.01), but their correlations with other environmental factors were weak. The RDA results further confirmed that cropping systems and soil pH greatly affected soil nutrient contents (Fig. 4). SOC and TN were positively correlated with aspect, topographic wetness index (TWI), and valley depth (VD), and negatively correlated with mean annual precipitation (MAP), mean annual temperature (MAT), slope and elevation (Fig. 4). TP was positively correlated with MAT and negatively correlated with VD, aspect and elevation (Fig. 4).

Fig. 3
figure 3

Distributions of soil organic carbon (SOC), total nitrogen (TN), total phosphorus (TP) in different cropping systems

Table 2 Spearman correlation coefficients among soil nutrient contents and environmental factors (n = 142)
Fig. 4
figure 4

Redundancy analysis ordination diagrams of environmental factors (red line and triangle) and soil nutrients (blue line)

3.4 Model performance and importance ranking

RF models were constructed to explore the relationships between environmental factors and soil nutrient contents. The values of model accuracy indices (MAE, RMSE, and R2) are shown in Table S1. In terms of the above three indicators, the RF model provided the best estimations of TN content (R2 = 0.53, MAE = 0.24 g/kg, RMSE = 0.32 g/kg) and the relatively low estimations of TP content (R2 = 0.30, MSE = 0.14 g/kg, RMSE = 0.19 g/kg).

The RF results show that cropping system followed by TWI and slope was the most primary factor for explaining the variation in SOC (Fig. 5a). The spatial variability of TN was mainly explained by cropping system, TWI and MAT (Fig. 5b). Soil pH followed by aspect and cropping system was the most important factor for explaining the variation in TP (Fig. 5c).

Fig. 5
figure 5

Factor relative importance rankings produced by random forest for (a) SOC, (b) TN, and (c) TP contents

The PDP results (Fig. 6) are basically consistent with the correlation analysis results (Table 2, Fig. 4). However, considering the nonlinear relationship, it can more specifically reveal how the top three factors in RF affect the prediction results. For SOC, the relative importance of environmental factors was ranked in the order of cropping system (13.20%) > TWI (12.06%) > slope (10.55%). Compared with maize monoculture, rice monoculture system contained more SOC. Meanwhile, the content of SOC increased with the increase of TWI, whereas decreased with the increase of slope (Fig. 6a–c). For TN, the relative importance of environmental factors is ranked in the order of cropping system (20.72%) > TWT (14.23%) > MAT (12.25%). Compared with maize monoculture, rice monoculture system contained more TN, and the TN content increased with the increase of TWI, whereas decreased with the increase of MAT (Fig. 6d-f). For TP, the relative importance of environmental factors is ranked in the order of soil pH (22.35%) > aspect (12.70%) > cropping system (10.60%). The TP content increased with the increase of soil pH, whereas decreased with the increase of aspect, in addition, compared with maize monoculture, rice monoculture system contained less TP (Fig. 6g–i).

Fig. 6
figure 6

Partial dependence plot between environmental factors and predicted SOC (a, b, c), predicted TN (d, e, f), predicted TP (g, h, i)

4 Discussion

4.1 Comparison of soil nutrient content and spatial variation

This study revealed the contents of SOC, TN, and TP under different cropping systems in southwest China. According to the soil nutrient classification standard in China, SOC, TN, and TP contents were classified as grades 4 (9.83 g/kg), 3 (1.12 g/kg), and 5 (0.7 g/kg) (NSSO, 1998) respectively, which were higher than their corresponding background and geochemical baseline values of China (Wang et al. 2016), suggesting that SOC, TN, and TP were relatively abundant in topsoil of the study area. The relatively abundant levels of soil nutrient contents in the study area may be related to the high intensity of fertilizer application and the remarkable atmospheric N deposition in southwest China (Rodrigues et al. 2021; Turmel et al. 2015; Jiang et al. 2017). Compared with other areas in the Three Gorges reservoir area, the TN and TP in the study area are basically the same as those in other areas, but the SOC content is lower than that in other areas (Zhang et al. 2017; Sun et al. 2021). This result might be attributed to the fact that the study area is agricultural land and frequent agricultural practices will cause a lot of nutrient loss (Chen et al. 2019). The spatial autocorrelation range of SOC and TN is similar and far larger than that of TP in our study, which is consistent with previous research (Zhang et al. 2010; Wang et al. 2017; Cao et al. 2021). This may be due to a highly coupled relationship between SOC and TN, but a decoupled relationship between SOC and TN and TP (Finzi et al. 2011; Müller et al. 2017). At the same time, the correlation analysis (Table 2) also confirms that SOC and TN are highly correlated (r = 0.88, p < 0.01), while the correlation between SOC and TP (r =  − 0.12) and between TN and TP are weak (r =  − 0.09).

4.2 Impact of the identified important factors on SOC content

The random forest (RF) model showed cropping system was the most important factor for SOC content in the study area (Fig. 5a). Previous studies have demonstrated that cropping system has a great influence on SOC (Zheng et al. 2016; Zhang et al. 2022). For example, Zheng et al. (2016) found that flooding conditions increase the number and activity of reducing bacteria in the soil under the rice cropping system, which led to the decrease of decomposition of organic matter and contributed to SOC accumulation. Zhang et al. (2022) reported that cropping system was the main factors linked to the stratification ratio of the SOC and rice-upland crop rotation systems had significantly higher stratification ratio than rice monoculture and upland crop rotation systems. Our analyses revealed the superiority of the soil under rice monoculture in sequestering SOC compared to maize monoculture (Fig. 6a), confirming the previous reported effect of cropping system on soil nutrients (Zheng et al. 2016). In this study, rice is mainly planted in paddy fields with flat topography, and maize is mostly distributed in dry lands with sloping fields. Under rice monoculture, abundant water and low topography resulted in high soil fertility; in addition, the large amount of crop residue in the paddy fields was favorable to retain SOC (Deng et al. 2016). Therefore, the accumulation of SOC in paddy field is relatively high. The low SOC content in maize fields may be caused by the following reasons: (1) compared with the natural ecosystem, the long-term and repeated tillage in maize planting areas promoted the aggregate destruction, and thus accelerated C mineralization (Wu 2011; Song et al. 2014); (2) the steep terrain of maize planting area made soil erosion more serious, leading to higher SOC loss (Li et al. 2012; Chen et al. 2019).

Topographic wetness index (TWI) and slope were other factors exerting important impacts on SOC content (Fig. 5a). They were the main topographic factors, which affect plant growth, soil erosion, and litter accumulation by changing hydrothermal conditions(Sun et al. 2015; Yu et al. 2020a). In general, the content of SOC decreased with the increase of slope, whereas increased with the increase of TWI (Fig. 6b–c). The results may be attributed to soil erosion, which can transport litters and topsoil from a higher slope to a lower slope, resulting in a higher SOC content at the bottom of the slope (Wei et al. 2010; Zhang et al. 2015). Besides, slope can significantly affect SOC content by changing soil pH (Zheng et al. 2021). TWI was often used to quantitatively simulate soil moisture conditions in a region. Relatively high moisture leads to strong chemical weathering of parent materials and consequently massive production of secondary clay minerals, plus high vegetation cover of this area, resulting in relatively high SOC content (Liu et al. 2020).

4.3 The main controlling factors on TN content

Numerous studies have indicated that cropping system was an extremely important factor controlling TN content (Ren et al. 2019; Zhang et al. 2022). The results of the RF model also revealed the importance of cropping system on TN dynamics (Fig. 5b). Moreover, in our study, TN under rice monoculture was significantly higher than that under maize monoculture (Fig. 6d), which is consistent with the results of previous studies (Ren et al. 2019). This may be due to rice mainly distributed in low-lying paddy fields, and its flooding condition can slow down the mineralization of N and the transformation of biomass, thus increase the accumulation of TN (Xue et al 2015; Zheng et al. 2021). The lower TN content under maize monoculture may be explained by the fact that maize is planted in dry land soil with purple parent material, where intense physical disturbance and steep topography promote soil N loss (Guo et al. 2011).

Topographic wetness index (TWI) was generally regarded as a major factor for TN content (Fig. 5b), which was used to characterize soil wetness at different landscape positions (Wang et al. 2012, 2018c). In this study, TN content raised with TWI increase (Fig. 6e). A similar finding was observed in previous report (Kumar and Singh 2016; Liu et al. 2020). For example, Kumar and Singh. (2016) showed that TWI was one of the topographic parameters most related to TN content. Liu et al. (2020) reported that TWI can influence TN content by affecting rock weathering. One possible reason was that TWI will affect water conditions, higher TWI indicates higher soil water content, which can reduce the decomposition rate of organic matter and promote mineral weathering, thus increasing TN content (Liu et al. 2020; Hu et al. 2021).

Mean annual temperature (MAT) also had relatively high explanatory ability to the spatial variability of TN in this study (Fig. 5b), and TN content raised with MAT decrease (Fig. 6f). Temperature is the key factor to control the transformation and migration of soil N (Wang et al. 2021). Generally, higher TN content was expected to be accumulated in low temperature environment (Liu et al. 2021a; Wang et al. 2021). The reason why temperature influences soil TN is that the content of TN was mainly determined by microbe N-fixation, soil N mineralization, and plant N uptake (Li et al. 2018; Tan et al. 2021), which were affected by temperature. High temperature can accelerate plant biochemical rate, thus increasing the absorption of N (Ngaba et al. 2019). Meanwhile, increased temperature will lead to high microbial N-fixation and soil N mineralization by enhancing microbial activity (Tan et al. 2021).

4.4 Dominant factors influencing the content of TP

The RF model showed that soil pH was a most important factor for TP (Fig. 5c). In this study area (4.5 < pH < 8.3), there was a significant positive correlation between TP content and soil pH (Fig. 6g). This was different with previous report that the content of TP dominated by inorganic P was independent of soil pH (Liu et al. 2021a). One possible reason is that the current study area is agricultural land, phosphorus fertilizer is the main source of TP in soil, whereas pH will affect the effectiveness of phosphorus fertilizer (Liao et al. 2017; Maharajan et al. 2021). However, some studies have also shown that the TP decreased with increasing soil acidity (pH) (Niederberger et al. 2019). This decrease may be explained by that the solubility and fixation of soil P is strongly affected by soil pH (Adhikari et al. 2017; Maharajan et al. 2021). Topsoil pH is generally between 4.5 and 8.5, which is conducive to the fixation of P and reduce the absorption of phosphorus by plants (da Cerozi and Fitzsimmons 2016). Meanwhile, in agricultural systems with high human activity interference, ongoing acidification and nitrogen deposition may lead to nutrient imbalances that affect TP content (Talkner et al. 2009).

Aspect and cropping system were also the dominant factors that affect the soil TP content (Fig. 5c). Our results showed that higher TP content on the shady slope in comparison to the sunny slope (Fig. 6h), which was in line with some reports (Måren et al. 2015). Aspect can affect the solar radiation of a place and thus temperature and moisture conditions, which affects plant growth and soil biochemical processes (Hoylman et al. 2018). On the sunny slope, there is sufficient water and heat, and the vegetation absorbs more P from the soil to satisfy its own growth. Additionally, owing to the difference of soil moisture and vegetation cover, soil erosion may vary between sunny slope and shady slope, resulting significant differences in TP content among distinct slope aspects (Beullens et al. 2014; Chen et al. 2019).The content of TP under maize monoculture was markedly higher than that under rice monoculture (Fig. 6i). This was probably attributed to the fact that the intensive P fertilization along with low P utilization efficiency under maize monoculture (Rodrigues et al. 2021). Relatively low TP content under rice monoculture can be explained by that the paddy field was flooded and created continuous anaerobic conditions, resulting in slower decomposition rate of mineral phosphorus (Han et al. 2020).

4.5 Factors with low impact of soil nutrient variability

Stratum is the basis for soil development and soil texture controls the formation of agglomerates (Zhou et al. 2020). Previous studies found that the soil texture and stratum commonly exerted a strong impact on SOC, TN, and TP contents (Wang et al. 2019; Zhou et al. 2020; Liu et al. 2021b). However, in our study, the effects of soil texture and stratum on the soil nutrients were inferior to the cropping systems and topography. This may be ascribed to the frequent agricultural activities and the complex topography of the study area weakens the influence of stratum and soil texture on soil nutrients.

5 Conclusions

In this study, the spatial distribution of soil nutrients in the fragile ecological zone of southwest China was revealed and the specific effects of environmental factors on soil nutrients under different cropping systems were quantitatively analyzed. The contents of SOC and TN in this study area showed abundant characteristics, with weak spatial dependence. TP content was enriched and it had strong spatial dependence. Meanwhile, compared with maize monoculture, rice monoculture contained higher SOC, TN, and lower TP contents.

Cropping system, pH, TWI, slope, MAT, soil texture, and stratum all contributed to the spatial variation in soil nutrients. However, for different soil nutrients, the relative importance of these factors varied greatly. Cropping system, TWI, and slope were the dominant factors affecting SOC variability. Cropping system, TWI, and MAT greatly contribute to the spatial variation of TN. Soil pH followed by aspect and cropping system explained most variation of TP. In summary, understanding the influence of different environmental factors on spatial variation of soil nutrient can provide theoretical reference for optimizing agricultural management practices, especially in ecologically fragile areas.