Introduction

Ecosystem services refer to the various benefits that humans directly or indirectly obtain from natural ecosystems, which specifically include four major types: provisioning services, regulating services, cultural services, and supporting services. They serve as a crucial link between human society and natural ecosystems1,2,3. Complex interaction mechanisms exist among these service types, which under the combined influence of natural conditions and socio-economic factors, may exhibit either trade-off relationships (where enhancement of one service leads to diminishment of another) or synergistic relationships (mutually reinforcing effects)4,5. According to the United Nations’ forecast, the global population is expected to exceed 10 billion by the end of the 21 st century. With the continuous growth of the global population and the changing structure of demands, the global ecosystem service functions are showing a continuous decline trend6, and it is estimated that the basic needs of billions of people will be difficult to be fully met7. The United Nations Millennium Ecosystem Assessment report indicates that over 60% of global ecosystem services are already in a degraded or unsustainable state, and if this degradation trend is not effectively curbed, it is highly likely to deteriorate significantly, causing profound impacts on human well-being8,9,10.

With the rapid advancement of 3S technologies (Remote Sensing, GIS, and GPS), assessment methodologies have gradually shifted toward model-based approaches within the biophysical quantification framework.. The InVEST model, as a representative ecosystem service assessment tool, integrates geospatial analysis techniques and features a multi-module evaluation system encompassing carbon storage, water yield, habitat quality, and soil conservation, among others11,12. It effectively incorporates ecosystem service research into management decisions and spatial quantification across different scales, clearly demonstrating the spatiotemporal heterogeneity of ecosystem services13. As ecosystem service research continues to deepen, investigating the positive or negative impacts of driving factors on ecosystem services has become a central focus in academia. Methodologically, various statistical approaches—including correlation analysis14, principal component analysis15,16, structural equation modeling14, geographical detectors17,18, and geographically weighted regression19,20—have been widely applied in studying the driving factors of ecosystem services, providing diversified methodological support for revealing their formation mechanisms. Due to the nonlinear and complex interactions between ecosystem services caused by natural and anthropogenic factors, traditional linear regression cannot be used to quantify the influence of one ecosystem service on another21,22. In ecosystem services research, machine learning algorithms have expanded the boundaries of traditional analytical methods. They not only efficiently process large-scale datasets but also effectively reveal complex nonlinear relationships among variables, demonstrating excellent stability and robustness. For instance, the XGBoost model has gained widespread application in this field due to its flexible structure, high computational efficiency, and broad applicability23,24. However, the inherent complexity and non-intuitive decision logic of such models often render them “black boxes,” limiting the interpretability of results. This opacity complicates understanding the nonlinear coupling mechanisms between influencing factors and ecosystem trade-offs/synergies, while also increasing the complexity of identifying threshold effects. To overcome these limitations, the SHAP (SHapley Additive exPlanations) method, combined with visualization tools, clearly displays the dependency relationships and interaction patterns among feature variables. It intuitively reveals the nonlinear influence pathways and threshold effects of driving factors, thereby providing deep mechanism interpretations that traditional analytical methods struggle to achieve.

As research continues to deepen, scale effects have been widely recognized as one of the key factors influencing the spatial distribution of ecosystem services (ES) and the trade-offs and synergies among them25,26. Scale plays a crucial role in shaping ecological patterns and processes, determining the characteristics and interrelationships of ES, and identifying their key driving forces27. In the dynamic analysis of ecosystem services, relying solely on results from a single spatial scale often fails to adequately reflect true patterns28. This approach struggles to reveal how the same driver influences changes in ecosystem services across different spatial levels, potentially leading to a mismatch between management strategies and actual service provision. Due to topographic variations, mountainous areas exhibit significant differences in natural conditions compared to plains. Altitudinal gradients not only cause vertical differentiation in climatic, soil, and vegetation characteristics but also lead to gradient changes in social factors such as population distribution and economic development, forming unique horizontal and vertical spatial patterns29,30,31. As a critical ecological barrier in North China, the Yanshan-Taihang Mountains region plays an irreplaceable role in water conservation, soil conservation, and biodiversity maintenance. However, in recent years, intensified climate change and human disturbances have led to continuous degradation of ecosystem functions in this area. Particularly in the southern Taihang Mountains, water conservation capacity has significantly declined, soil erosion has worsened in localized areas, and wildlife habitat fragmentation has become increasingly severe32. Meanwhile, as a former contiguous poverty-stricken region, the conflict between economic development and ecological conservation remains prominent. The current economic growth model still heavily relies on natural resource exploitation, while ecological protection has long been neglected. This has resulted in frequent ecological issues such as intensified soil erosion, worsening water scarcity, and declining vegetation coverage, which not only threaten regional ecological security but also severely constrain the potential for sustainable economic development.

This study selected the Yanshan-Taihang Mountain area as the research area and applied the InVEST model to quantitatively assess four key ecosystem services—carbon storage, habitat quality, water yield, and soil conservation—from 2000 to 2023. The Getis-Ord Gi* statistic was employed to identify cold and hot spots of ecosystem services across multiple spatial scales. Bivariate local spatial autocorrelation analysis was conducted using GeoDA software to spatially characterize the trade-offs and synergies among ecosystem services. Furthermore, the XGBoost-SHAP model was utilized to identify the key driving factors influencing these services. Through multi-scale quantitative analysis, this study reveals the spatial heterogeneity and scale dependency of ecosystem services. It aims to provide a robust scientific foundation for regional ecological conservation and restoration, enabling more precise and effective ecological management strategies. Ultimately, this enhances regional ecological security functions and supports sustainable regional development.

Study area overview

The study area comprises two major mountain systems (Figure 1). The Taihang Mountain region, which includes the Taihang Mountains and their adjacent areas, is situated geographically between 34°34’–40°43’N and 110°14’–114°33’E. This north–south oriented region extends across four provincial-level administrative divisions—Beijing, Hebei, Shanxi, and Henan—and constitutes a representative transboundary physiographic unit. Characterized by a predominantly mountainous landscape interspersed with hilly and plain areas, the region experiences a temperate semi-humid continental monsoon climate, marked by distinct seasonal variations and concentrated rainfall. The second mountain system, the Yanshan Mountains, is located between 39°40’–42°10’N and 115°45’–119°50’E. This ecotonal zone connects the North China Plain to the south, the Bohai Sea to the east, the Loess Plateau to the west, and the Mongolian Plateau to the north. Featuring a topographic gradient that rises from the southeast to the northwest, with steep slopes and complex valley systems, it exhibits typical folded mountain landforms under a warm-temperate continental monsoon climate, characterized by strong seasonality. These two mountain systems, each distinguished by distinct geographic positions, orientations, and climatic conditions, jointly constitute a vital ecological security barrier for North China.

Fig. 1
figure 1

Study area map.

Research methodology

InVEST model

To evaluate the spatiotemporal distribution characteristics and changing patterns of ecosystem services in the Yanshan-Taihang Mountains region, the InVEST model was employed to calculate four key ecosystem service indicators - carbon storage, habitat quality, water yield, and soil conservation - for the years 2000, 2012, and 2023. The specific calculation methods are detailed in Table 1.

Table 1 Calculation formulas for four ecosystem services.

Hot spot analysis

Hot spot analysis is a spatial statistical technique designed to identify clustering patterns in geospatial data, specifically distinguishing areas with statistically significant concentrations of high values (hot spots) and low values (cold spots). This study employed the Getis-Ord Gi* analysis tool within ArcGIS to detect cold/hot spot distributions of ecosystem services across the study area. The determination criteria are based on two key statistical outputs:

  • Hot spots: Z-score > 0 with statistically significant P-value (typically P < 0.05)

  • Cold spots: Z-score < 0 with statistically significant P-value(typically P < 0.05)

Bivariate local spatial autocorrelation

To deeply explore the spatial correlation characteristics among multiple variables, scholars have innovatively proposed the bivariate spatial autocorrelation index based on the traditional Moran’s I index. Compared with the univariate analysis, this method can effectively reveal the interactive correlation of different geographical elements in spatial distribution33 This study conducts bivariate local spatial autocorrelation analysis based on the GeoDa software, aiming to systematically analyze the trade-off and synergy relationship and its dynamic evolution law of two ecosystem services in the study area at the spatial scale. The analytical results are interpreted through four characteristic spatial clusters:

  • HH (High-High) and LL (Low-Low): Indicate spatial synergy (positive covariation) between services

  • HL (High-Low) and LH (Low-High): Reveal spatial trade-offs (negative covariation) between services

XGBoost-SHAP algorithm model

The eXtreme Gradient Boosting (XGBoost) algorithm represents an advanced machine learning technique developed by Chen et al.34 as an enhancement to traditional gradient boosting decision trees. This innovative approach demonstrates three key advantages over conventional methods: superior generalization capability, enhanced scalability, and accelerated computational efficiency. The algorithm employs an iterative learning strategy that progressively improves prediction accuracy through sequential construction of regression trees, each designed to correct residuals from previous models. For model interpretability analysis, this study incorporates SHapley Additive exPlanations (SHAP), a game theory-based approach introduced by Lundberg et al.35. The SHAP framework quantifies feature importance by calculating the average marginal contribution of each feature a cross all possible feature combinations, ensuring fair attribution of predictive influence. Compared to conventional interpretability methods (e.g., LIME), this method not only provides both global and local feature importance assessments, but also supports multi-dimensional visualization, allowing users to intuitively understand the feature contributions and decision logic of the model, thereby significantly improving the interpretability and decision credibility of machine learning models.

Data and methods

The study utilized multi-temporal datasets (2000, 2012, 2023) encompassing land use, natural factors, and socioeconomic data. Topographic data (DEM and slope) and vegetation indices (NDVI) were obtained from NASA EarthData (https://www.earthdata.nasa.gov), while meteorological parameters (temperature, precipitation, and potential evapotranspiration) were acquired from the National Tibetan Plateau Data Center (https://data.tpdc.ac.cn). Soil characteristics were derived from the China soil dataset within the Harmonized World Soil Database (http://westdc.estgis.ac.cn/), with demographic data sourced from the LandScan population database (https://landscan.ornl.gov). Economic indicators (GDP) came from the Resource and Environment Data Cloud Platform of the Chinese Academy of Sciences (http://www.resdc.cn), and nighttime light data were extracted from Earth System Science Data (https://www.earth-system-science-data.net). Specifically, terrain data employed NASA’s SRTMDEMUTM 90-meter resolution digital elevation model product; vegetation index data sourced from MODIS’s MOD13 product. To ensure spatial consistency, all datasets were uniformly projected into the WGS_1984_UTM_Zone_50N coordinate system and resampled to a 1000-meter spatial resolution. Additionally, all raster data were clipped using the vector boundaries of the study area.

The data foundation and parameter settings of this study mainly come from existing academic literature, which includes relevant measured data and model calibration data. Based on these data, we set the key parameters necessary for the operation of the InVEST model and ultimately quantitatively evaluated four key ecosystem service capabilities36,37,38,39. Within the carbon storage module, carbon pool coefficients were primarily calibrated using existing field monitoring data from this region or measured data from adjacent areas, with specific values presented in Table 2. For the habitat quality module, parameters such as threat factor weights, maximum influence distance, and decay type (linear or exponential) are detailed in Table 3. The Half-Saturation Constant was uniformly set to 0.5. In the water yield module, the Z value was determined based on the water yield coefficient data from the Hebei Province Water Resources Bulletin. After comparing simulation results with measured values, Z = 1.25 was selected as the optimal parameter due to its minimal error. The biophysical coefficients of water yield modulus are shown in Table 4. For the soil conversation module, parameters such as plant-available water content and crop coefficient (Kc) were calculated using existing literature references. The R, K, C, and P factors were assigned values based on prior research findings. Selected parameters are listed in Table 5. For spatial analysis, this study employed the GeoDa platform to perform Getis-Ord Gi* hotspot analysis and bivariate LISA analysis. The spatial weight matrix was defined using the queen adjacency criterion (i.e., units sharing boundaries or vertices are considered adjacent). All analyses underwent 999 Monte Carlo permutations with a significance level set at p < 0.05. Furthermore, integrating the natural geographical characteristics of the Yanshan-Taihang Mountains region with existing research foundations, this study selected four spatial scales—1 km×1 km, 5 km×5 km, 10 km×10 km, and 15 km×15 km—to conduct multidimensional ecosystem service analysis from micro to macro scales. The 1 km scale focuses on resolving the detailed impacts of local topography and vegetation cover on ecosystem service provision, such as urban green spaces and isolated agricultural patches. The 5 km scale is suitable for identifying mesoscale ecological functional spatial patterns, such as small watersheds and patch complexes. The 10 km scale effectively captures regional functional characteristics, such as forest communities and agricultural landscapes. The 15 km scale reveals large-scale ecosystem service network features. The 5 km×5 km grid fully encompasses woodlands, adjacent farmlands, and small water bodies, comprehensively reflecting ecological service interactions between landscape units. The 10 km and 15 km scales aid in understanding regional functional positioning, revealing potential conflicts between economic development and ecological regulation at watershed or county levels.

Table 2 Biophysical coefficients of the carbon storage module.
Table 3 Biophysical coefficients of the habitat quality module.
Table 4 Biophysical coefficients of the water yield module.
Table 5 Biophysical coefficients of the soil conservation module.

Results

Analysis of spatio-temporal changes in ecosystem services

Temporal analysis reveals distinct evolutionary patterns in ecosystem services from 2000 to 2023. Carbon storage demonstrated sustained growth, increasing from 2444.36 TgC to 2510.68 TgC (2.71% cumulative growth). Conversely, habitat quality exhibited continuous decline, with mean values decreasing from 0.5880 to 0.5455. Both water yield and soil conservation services showed similar "increase-then-decrease" trajectories: water yield rose from 78.71mm (2000) to 107.77mm (2012) before declining to 89.78mm (2023), while soil conservation increased from 143.81 t·hm−2 to 175.24 t·hm−2, then decreased to 162.03 t·hm−2. These findings are consistent with previous studies37. Spatial distribution characteristics (Figure 2) demonstrate marked heterogeneity across all four ecosystem services. Carbon storage displayed a concentric pattern with higher values in central forested areas (eastern Shanxi, western/northern Hebei) featuring superior vegetation coverage and soil organic carbon, contrasting with peripheral urban zones. The spatial distribution of habitat quality is closely linked to land use types. As shown in the figure, the forest and grassland ecosystems in the central Taihang and Yanshan mountain ranges exhibit the highest habitat quality, while surrounding urban and agricultural areas demonstrate a significant decline. Water yield exhibited south-high/north-low distribution, peaking in southern Taihang and eastern Yanshan regions due to combined topographic and climatic influences. Soil conservation capacity was strongest in southern areas where steeper slopes, greater precipitation, and dense vegetation enhanced runoff interception and erosion control, while marginal croplands and urban areas showed weakest performance due to sparse vegetation and exposed surfaces.

Fig. 2
figure 2

Spatial distribution patterns of ecosystem services in the Yanshan-Taihang mountains region (2000-2023).

Spatial correlation analysis

To investigate the spatial differentiation characteristics and dynamic evolution patterns of ecosystem services in the Yanshan-Taihang Mountain region, this study employed ArcGIS 10.8 software to construct four distinct spatial analysis scales using grid resolutions of 1 km×1 km, 5 km×5 km, 10 km×10 km, and 15 km×15 km. Zonal statistics were applied to extract ecosystem service raster data into each grid unit at the respective scales, followed by multi-scale spatial autocorrelation analysis. As presented in Table 6, global spatial statistical analysis based on the Moran’s I index revealed that from 2000 to 2023, the four ecosystem services—carbon storage, habitat quality, water yield, and soil conservation—demonstrated statistically significant positive spatial autocorrelation across multiple scales (Moran’s I > 0, p < 0.01). This indicates that these services exhibit distinct spatial clustering characteristics within the study area40,41,42. The observed spatial clustering effect shows clear scale dependency, with the Moran’s I index reaching its peak at the finest spatial resolution (1 km×1 km). As the spatial analysis scale increases, the intensity of spatial autocorrelation gradually diminishes.

Table 6 Global Moran’s I index of four ecosystem services in the Yanshan-Taihang Mountains.

The hot spot analysis results based on the Getis-Ord Gi* statistic (see Figure 3) showed that from 2000 to 2023, the spatial distribution of the four types of ecosystem services had certain similarities, but also obvious regional differences. The letters a, b, c, and d in the figure represent spatial scales of 1 km, 5 km, 10 km, and 15 km, respectively (the same applies below). The significant hot spots of carbon storage were primarily concentrated in the central regions of the Taihang and Yanshan Mountains, while the significant hot spots of habitat quality were mainly distributed in the central part of the Taihang Mountains and the northern part of the Yanshan Mountains. These areas, due to good vegetation coverage, have strong ecosystem service supply capabilities. The significant cold spots of carbon storage and habitat quality were highly overlapping, mainly concentrated in the peripheral edge areas of the Taihang Mountains, where the land is mainly cultivated and unused, with poor vegetation coverage and a single planting structure, leading to a significant decline in biodiversity. The spatial distribution pattern of water yield was unique, with significant hot spots mainly located in the southern and northeastern parts of the study area, and significant cold spots concentrated in the Yanshan region. The area proportion of cold spots showed a trend of first decreasing and then increasing. Soil conservation services presented different spatial distribution characteristics, with significant hot spots mainly distributed in the central part of the Taihang Mountains and sporadically in the Yanshan region; significant cold spots were mainly located in the peripheral areas of the study area, but overall, non-significant areas were dominant.

Fig. 3
figure 3

Spatial distribution of cold spots and hot spots for ecosystem services in the Yanshan-Taihang Mountains region (2000-2023).

Trade-off and synergy analysis of ecosystem services

To enhance the accuracy and scientific rigor of assessing the spatial interaction patterns of four key ecosystem services—carbon storage (CS), habitat quality (HQ), water yield (WY), and soil conservation (SC)—in the Yan-Taihang Mountain region, this study employed GeoDa software for quantitative analysis and visualization. The results are presented in Table 7 and Figure 4.

Table 7 Correlation coefficients of ecosystem services in the Yanshan-Taihang Mountains region.
Fig. 4
figure 4

Changes in correlation coefficients between multi-scale ecosystem services.

Table 7 and Figure 4 illustrate the trade-offs and synergies among the four ecosystem services (ES) at different scales in the study area. The study found that the Moran’s I index for the four ES exhibited significant differences across multiple scales, with both trade-offs and synergies present. Although the direction of the relationships between ES did not change significantly with increasing scale, the intensity of these relationships showed notable differences. Carbon storage, habitat quality, and soil conservation consistently exhibit significant positive spatial associations (Moran’s I > 0), forming stable synergistic effects. Among these, the spatial synergy between carbon storage and habitat quality shows a steady increase, with the Moran’s I index reaching its maximum value in 2023; the synergistic effects between carbon storage and soil conservation, as well as between habitat quality and soil conservation, develop in a pattern of initial increase followed by decline. Water yield consistently exhibits a negative spatial correlation with carbon storage and habitat quality (Moran’s I < 0), with spatial trade-off effects remaining relatively stable. The spatial correlation pattern between water yield and soil conservation exhibits significant temporal variability, transitioning from a synergistic effect in 2000 to a trade-off effect after 2012, and then reverting to a synergistic relationship in 2023 at the 15 km×15 km scale.

From a spatial perspective, as shown in Figure 5, the trade-off synergistic relationships among ecosystem services exhibit significant spatio-temporal heterogeneity. The combinations of ecosystem services represented by each net panel show distinct spatial differentiation in terms of both rate and direction of change. In the bivariate local spatial autocorrelation analysis, significant synergistic relationships were found between carbon storage, habitat quality, and soil conservation, primarily manifested as high-high clustering and low-low clustering distributions. At the 5 km×5 km analysis scale, CS-SC and HQ-SC are dominated by high-high clustering in the south and east, with low-low clustering around the periphery. The area proportion of the synergy region remains between 36.44% and 43.57%. In contrast, water yield shows a significant trade-off relationship with the other three ecosystem services, mostly in the form of low-high and high-low clustering. Specifically, WY-CS and WY-HQ are dominated by trade-off effects in the central and southern parts of the Taihang Mountains and the Yanshan region, with the area proportion of the trade-off region ranging from 37.53% to 52.15%. The synergy effect of WY-SC is mainly concentrated in the non-edge areas of the southern Taihang Mountains. Over time, the proportion of the synergy area first decreases and then increases. The trade-off areas are mainly located in the peripheral areas of the study region, and the area of the trade-off effect first increases and then decreases over time. In 2023, the proportion of the trade-off area in the study region is slightly larger than that of the synergy area.

Fig. 5
figure 5

Bivariate local spatial autocorrelation and clustering distribution of four ecosystem services (2000-2023).

Driving factor analysis

XGBoost model regression analysis

To accurately assess the reliability of the analysis results, this paper employs the variance inflation factor (VIF) method to examine multicollinearity among the influencing factors. Based on the magnitude of VIF values, multicollinearity levels were categorized into three types: VIF ≥ 100 indicates severe multicollinearity, 10 ≤ VIF < 100 indicates strong multicollinearity, and 0 < VIF < 10 indicates no multicollinearity. The VIF values for the eight selected factors—elevation, slope, annual precipitation, annual mean temperature, NDVI, GDP, population density, and nighttime light index—range from 1.59 to 5.43, all below 10. This indicates no multicollinearity issues among the ecosystem service factors. Therefore, the eight selected factors—X1 (elevation), X2 (slope), X3 (annual precipitation), X4 (annual mean temperature), X5 (NDVI), X6 (GDP), X7 (population density), and X8 (nighttime light index)—were ultimately chosen for further analysis of their impact on ecosystem service capacity.

This study employed an XGBoost regression model to predict and evaluate four ecosystem services: carbon storage, habitat quality, water yield, and soil conservation. XGBoost demonstrates strong nonlinear fitting capabilities and generalization performance by integrating multiple regression trees and progressively optimizing residuals. Across ecosystem services at different scales, we divided the raw dataset into training and testing sets37, with 70% of samples used for model training and the remaining 30% for evaluating model generalization. Model hyperparameters are shown in Table 8. During training, K-fold cross-validation was employed to assess model robustness and parameter sensitivity. Results demonstrated superior predictive performance on the training set compared to the test set, with all training sets achieving an R2 coefficient exceeding 0.87, indicating high predictive accuracy for unseen data. Statistical tests further confirmed that the residuals of the four ecosystem services satisfied the model assumptions, validating the applicability and superiority of the XGBoost regression model in ecosystem service assessment. Figure 6 presents the test and validation set results for each ecosystem service at a 5 km×5 km scale based on the XGBoost model.

Table 8 Hyperparameters of the XGBoost regression model.
Fig. 6
figure 6

Test set and validation set results based on the XGBoost model.

Interpretability analysis of the SHAP model

This study analyzes the results of prediction models for four ecosystem services using the XGBoost machine learning algorithm combined with the SHAP model interpretation method. As shown in Figures 7 and Figures 8, there are significant differences in the key driving factors of different ecosystem services across the four scales: carbon storage ecosystem services are primarily influenced by vegetation cover (Normalized Difference Vegetation Index, NDVI), topographic factors (slope), and human activity intensity (population density) across all four scales. As the scale increases, the influence of slope on carbon storage gradually surpasses that of NDVI, with slope becoming the dominant factor. Habitat quality services are primarily determined by terrain characteristics (slope, elevation) and human activity intensity (population density); Water yield services are primarily influenced by climate conditions (annual precipitation) and human activity intensity (population density). As the scale increases, the influence of slope and annual average temperature on water yield gradually surpasses that of NDVI; soil conservation services are primarily influenced by a combination of terrain factors (slope), climate conditions (precipitation), and vegetation cover status (NDVI).

Fig. 7
figure 7

Bar chart illustrating the relative importance of carbon storage, habitat quality, water yield, and soil retention in the Yanshan-Taihang mountain region.

Fig. 8
figure 8

SHAP feature analysis of carbon storage, habitat quality, water yield, and soil conservation in the Yan-Taihang Mountain region.

Figure 9 shows the results of feature dependency analysis based on the SHAP method, intuitively presenting the impact of each input feature on the model prediction results.

Fig. 9
figure 9

Analysis of key factors influencing ecosystem services in the Yanshan Taihang mountains based on SHAP dependency graph.

The analysis of carbon storage influencing factors reveals that NDVI and slope are key topographic features determining carbon storage, both exhibiting nonlinear relationships with carbon sequestration. When NDVI is at a low level, its SHAP value is negative, indicating that sparse vegetation inhibits carbon accumulation. However, when NDVI exceeds 0.45, its positive effect on carbon storage becomes apparent, showing an exponential growth trend as NDVI increases. Similarly, as slope increases, its negative impact on carbon storage gradually shifts to a positive effect, with steeper slopes contributing to higher carbon storage. Low population density demonstrates a significant positive contribution to carbon storage, whereas increased population density may lead to phenomena such as urban expansion and reduced vegetation cover, thereby decreasing carbon storage.

The analysis of habitat quality driving mechanisms reveals that population density is a key topographic factor regulating habitat quality. When human disturbance is minimal, ecosystems maintain their pristine state, resulting in higher habitat quality. However, when population density exceeds a critical threshold, urbanization may lead to habitat fragmentation, pollution, and other factors that negatively impact habitat quality. The relationship between habitat quality and topographic factors (such as slope and elevation) typically exhibits complex nonlinear characteristics rather than simple linear increases or decreases. When slope exceeds 8° or elevation surpasses 900 meters, the inhibitory effect of topographic factors on habitat quality gradually diminishes, subsequently reversing into a promotional effect, and ultimately stabilizing. This nonlinear transition is primarily driven by the “threshold effect” of ecological factors, coupled with the combined influence of species adaptability and environmental filtering mechanisms. At low slope and low elevation stages, human activities compete with wildlife for space and resources, introducing direct disturbances like hunting, noise, and light pollution that degrade habitat quality. Once critical thresholds are exceeded (e.g., slope 8°, elevation 900 m), further increases in slope or elevation may paradoxically reduce human disturbance, alleviate interspecies competition pressure, or create unique microclimates and soil conditions (e.g., cloud-forest zones at high elevations enhance humidity). These factors provide refuges or resource-rich zones for specific biological groups, manifesting as improved habitat quality. Ultimately, this relationship stabilizes, likely because when slopes become extremely steep or elevations reach great heights, habitat conditions tend toward harshness and homogeneity. The influence of environmental factors approaches saturation, and habitat quality no longer undergoes significant changes in response to variations in topographic factors, thereby establishing a new dynamic equilibrium.

The analysis of water yield driving mechanisms demonstrates that annual precipitation is the key factor influencing water yield. Under arid conditions, soil moisture deficit is significant, with precipitation primarily consumed by vegetation interception and soil infiltration. As annual precipitation increases, its positive effect on water yield shows a markedly enhanced trend. Population density exerts a dynamic nonlinear influence on ecosystem water yield. At lower population densities, human activities typically manifest as extensive exploitation of natural land, such as forest clearing and unregulated construction. These practices weaken vegetation’s water conservation capacity and soil’s water storage function, leading to increased surface runoff and reduced infiltration. Consequently, they exert a significant and highly volatile negative impact on water yield. As population density further increases, the underlying mechanisms become more complex. On one hand, populations tend to concentrate in areas with better water endowment, forming spatial co-occurrence patterns. On the other hand, high-density societies foster economies of scale and more efficient governance structures, driving water resource management from passive adaptation to active regulation. Large-scale water infrastructure construction enhances temporal and spatial water allocation capabilities; the adoption of water-saving technologies and water treatment processes improves utilization efficiency; and stringent environmental regulations coupled with ecological restoration projects gradually restore ecosystems’ water conservation functions. At this stage, the synergistic effects of multiple interventions stabilize the impact of population density on water yield. Slope plays a pivotal role in regulating water yield within ecosystems. Gentle slopes significantly prolong the retention time of surface precipitation, creating favorable conditions for water infiltration and thereby enhancing water yield. As terrain slope increases, precipitation rapidly transforms into surface runoff, drastically shortening the contact time between water bodies and the surface. This severely limits soil infiltration processes and groundwater recharge opportunities, ultimately suppressing water yield.

The analysis of driving mechanisms for soil conservation reveals that slope, as a key topographic factor, exerts significant regulatory effects on soil conservation function. In extremely low-slope areas, slow surface runoff may lead to waterlogging erosion, thereby weakening soil conservation capacity. As slope increases, enhanced gravitational effects help reduce water conservation time and mitigate the risk of submergence, consequently improving soil conservation. Regarding climatic factors, annual precipitation shows a significant positive correlation with soil and water conservation capacity. SHAP value analysis indicates that as precipitation increases, its contribution to soil conservation shifts from negative to positive, with moderate moisture increases promoting vegetation growth, enhancing soil structure stability, and improving soil and water conservation functions. The increase in NDVI also plays a crucial role in soil conservation. When NDVI falls below 0.45, vegetation cover is insufficient, resulting in limited soil and water conservation functions. Once NDVI exceeds this threshold, its conservation benefits significantly increase and continue to improve. When the NDVI falls below 0.45, insufficient vegetation cover limits its conservation capacity. Beyond this threshold, its conservation benefits significantly increase and continue to improve. Vegetation consolidates soil through root systems, reducing wind and water erosion43, while the canopy mitigates the direct impact of raindrops on soil, decreasing surface runoff. Additionally, decomposed litter increases soil organic matter, further enhancing erosion resistance. Together, these factors demonstrate the complex interplay between topography, climate, and vegetation in sustaining soil conservation capacity.

Analysis of interaction effects among driving factors

This study focuses on analyzing the interaction effects between key driving factors in various ecosystem services. As shown in Figure 10, in areas with higher slopes, as population density decreases and NDVI increases, their negative impacts on carbon storage and habitat quality gradually weaken and eventually turn into positive promotion. The mechanism of this transformation can be mainly attributed to the following two aspects: on the one hand, high slope areas are less affected by human activities, and vegetation has better natural restoration conditions. The increase in coverage directly enhances the carbon sink function of the ecosystem; On the other hand, steep terrain limits land development and high-intensity use, reducing human pressure after a decrease in population density, allowing natural habitats to recuperate, thereby facilitating the maintenance of biodiversity and overall improvement of habitat structure.

Fig. 10
figure 10

Interaction effects among driving factors.

In regions with abundant annual precipitation, the increase in NDVI jointly drives shifts in both water yield and soil conservation capacity, transforming its impact from inhibitory to promotional. This transition hinges on mature vegetation’s robust canopy interception, litter water storage, and soil infiltration capabilities, which effectively convert greater precipitation into stable groundwater recharge and baseflow. The positive benefits of water conservation ultimately outweigh the earlier negative effects of water consumption due to evapotranspiration. Simultaneously, high-coverage vegetation fundamentally controls soil erosion through deep root systems that consolidate soil, and through canopy and litter layers that reduce rain splash and runoff scouring. Furthermore, in areas with high NDVI, the impact on water yield shifts from positive promotion to negative suppression as slope increases; conversely, the effect on soil conservation capacity shifts from negative weakening to positive enhancement. The core mechanism behind this shift lies in altered water pathways and erosion dynamics. At low to moderate slopes, increased gradient accelerates subsurface runoff convergence, boosting water yield while simultaneously intensifying runoff erosion and diminishing soil conservation capacity. At steep slopes, shallow soil layers drastically reduce water conservation capacity, making vegetation transpiration the primary water expenditure and causing water yield to decline. However, the extensive root networks of vegetation play a decisive role in resisting gravitational forces and runoff erosion. Their ecological value in soil stabilization becomes prominent, significantly enhancing soil conservation capacity.

Discussion

Mountainous residential environments exhibit high spatial heterogeneity and dynamic complexity, stemming from the dual influence of natural factors and human activities44,45. The research reveals intricate interactions among ecosystem services in this region. Specifically, habitat quality, carbon storage, and soil conservation exhibit strong positive synergistic relationships, while water yield demonstrates trade-off characteristics with other services—a finding consistent with previous studies46.

Among natural drivers, slope is identified as a key common factor influencing all four ecosystem services. Areas with gentler slopes typically experience stronger human disturbances, such as agricultural expansion and urban development, leading to reduced vegetation cover, loss of soil organic carbon, weakened carbon sequestration capacity, and increased habitat fragmentation. In lowland areas of the Yanshan Mountains, where loess or weathered granite dominates, the weak erosion resistance, makes these regions more susceptible to water erosion. High-coverage vegetation (e.g., forests, grasslands) exhibits superior carbon sequestration capacity compared to other land-use types (e.g., croplands, built-up areas), contributing significantly to the spatial distribution of carbon storage47. Moreover, precipitation is the primary factor influencing WY, significantly affecting the quantity of water resources and terrestrial hydrological processes48. The spatio-temporal variability of precipitation patterns strongly regulates water yield distribution, further influencing the balance of other ecosystem services—a conclusion aligned with Zuo et al.’s findings in Beijing’s ecological conservation redline zones49.

Based on the research findings of the ecosystem service driving mechanisms in the Yanshan-Taihang Mountain region, it is recommended to establish a differentiated ecological management system based on topographic gradients. Specifically, steep slope areas should be designated as core ecological protection zones, where the strictest conservation measures will be implemented to limit human disturbances. High-altitude villages should be systematically relocated to low-interference areas, with a focus on protecting native vegetation communities and soil carbon storage functions. In moderate slope areas, eco-agroforestry systems can be developed according to local conditions, promoting contour farming and soil conservation projects to achieve a balance between ecological preservation and agricultural production. For gentle slope areas, urban development boundaries should be scientifically delineated, and ecological infrastructure such as greenbelt systems and sponge facilities should be constructed to maintain a dynamic equilibrium between urbanization and ecological protection. Regarding vegetation restoration and carbon sequestration enhancement, a tiered management approach is advised. For degraded areas with NDVI values below 0.45, priority should be given to ecological restoration using native tree species such as Pinus tabuliformis and Quercus wutaishanica, establishing a progressive succession model from herbaceous plants to shrubs and then to trees. For forests with NDVI values between 0.45 and 0.6, precision forest quality improvement projects should be implemented, coupled with the exploration of carbon trading mechanisms to provide long-term economic incentives for steep-slope forest conservation. In terms of water resource management, differentiated strategies should be adopted based on regional precipitation characteristics. In arid regions with low annual precipitation, water-saving technologies such as rainwater harvesting cisterns and dryland terraces should be prioritized to improve water-use efficiency. Meanwhile, the introduction of digital monitoring technologies is recommended to establish a dynamic water resource monitoring and early warning system, enabling intelligent management of water utilization and ecological conservation.

Conclusions

Research conclusions

  1. (1)

    From 2000 to 2023, carbon storage exhibited steady growth, displaying a ring-shaped distribution pattern with lower values at the periphery and higher values in the central region. The habitat quality index showed a continuous decline, with high-value areas primarily concentrated in the central Taihang Mountains and the Yanshan region. Water yield and soil conservation followed similar trends, with mean values initially increasing before decreasing. Water yield distribution was characterized by higher values in the south and lower values in the north, while high soil conservation capacity was mainly observed in the southern part of the study area.

  2. (2)

    Global spatial statistical analysis based on the Moran’s I index revealed that from 2000 to 2023, the four ecosystem services—carbon storage, habitat quality, water yield, and soil conservation—demonstrated statistically significant positive spatial autocorrelation across multiple scales (Moran’s I > 0, p < 0.01). This indicates that these services exhibit distinct spatial clustering characteristics within the study area. The observed spatial clustering effect shows clear scale dependency, with the Moran’s I index reaching its peak at the finest spatial resolution (1 km × 1 km). As the spatial analysis scale increases, the intensity of spatial autocorrelation gradually diminishes.

  3. (3)

    The Moran’s I index for the four ES exhibited significant differences across multiple scales, with both trade-offs and synergies present. Although the direction of the relationships between ES did not change significantly with increasing scale, the intensity of these relationships showed notable differences. Carbon storage, habitat quality, and soil conservation consistently exhibit significant positive spatial associations (Moran’s I > 0), forming stable synergistic effects. Among these, the spatial synergy between carbon storage and habitat quality shows a steady increase, with the Moran’s I index reaching its maximum value in 2023; the synergistic effects between carbon storage and soil conservation, as well as between habitat quality and soil conservation, develop in a pattern of initial increase followed by decline. Water yield consistently exhibits a negative spatial correlation with carbon storage and habitat quality (Moran’s I < 0), with spatial trade-off effects remaining relatively stable. The spatial correlation pattern between water yield and soil conservation exhibits significant temporal variability, transitioning from a synergistic effect in 2000 to a trade-off effect after 2012, and then reverting to a synergistic relationship in 2023 at the 15 km × 15 km scale.

  4. (4)

    The XGBoost regression model demonstrated strong predictive performance on both training and testing datasets, with better accuracy on the training set. SHAP model analysis indicated that slope significantly influenced all four ecosystem services. Population density primarily affected carbon storage, habitat quality, and water yield; NDVI mainly influenced carbon storage and soil conservation; and annual precipitation played a crucial role in water yield and soil conservation.

Limitation

This study has some shortcomings in the assessment of ecosystem services. The InVEST model treats the four carbon pools within the same land use type as homogeneous in the carbon stock calculation module, failing to reflect the actual differences between carbon pools50. In the water yield calculation, the model only considers precipitation and evapotranspiration while neglecting key hydrological processes such as runoff, glacier meltwater, and permafrost, which may lead to deviations in water yield estimates51,52. Although the XGBoost model performs well in predicting ecosystem services, its modeling process is still based on several assumptions and simplifications, which limits the model’s ability to capture sudden or policy driven human activity disturbances such as severe land use changes or extreme climate events53. To gain a deeper understanding of the trade-offs and synergies among ecosystem services, it is necessary to comprehensively consider the diverse and complex driving factors behind them. Although existing research often links such mechanisms with intrinsic feedback between land use, climate change, topography, vegetation cover, and services, it is still difficult to comprehensively cover all causes54,55. Therefore, future research should focus on integrating real-time monitoring data with improved modeling methods, by introducing more policy sensitive dynamic variables, enhancing the model’s responsiveness to complex reality and simulation realism, thereby improving the scientific and rigorous nature of ecosystem assessment.