Introduction

The exacerbation of water scarcity can be attributed to water pollution1,2, which is a substantial concern, particularly in regions already facing water shortages3. The availability of clean water is a prominent determinant of the health and well-being of residents, as well as a crucial factor in socioeconomic development4,5. Nevertheless, the interaction between climate change and urbanization is currently intensifying challenges related to water scarcity in river systems6,7. Temperature plays a pivotal role in regulating river ecosystem dynamics8, notably influencing water quality through the sequential regulation of water temperature, evapotranspiration, the utility of runoff, and the physicochemical-biological responses9. Additionally, an increase in temperature can enhance the frequency and duration of extreme heat events10, increasing the level of pollution in rivers9. This introduces a considerable degree of uncertainty in water quality management and challenges the achievement of the United Nations (UN) Sustainable Development Goals (SDGs) for clean water.

The impact of temperature on water quality is a cumulative and long-term phenomenon that demands particular attention in light of the current climate change. Under conventional temperature, the Intergovernmental Panel on Climate Change’s Sixth Assessment Report explicitly indicates water quality degradation associated with increased water and surface air temperature11. Extreme temperature during drought and heatwaves has been demonstrated to degrade water quality by reducing river runoff and affecting the rate of biogeochemical processes9,12,13,14. Furthermore, previous studies have also confirmed the robust relationships between air temperature and water quality changes through specific watersheds15,16 and particular indicators17,18,19, providing a degree of qualitative insight. Despite extensive investigations and documentation of the effects of temperature on water quality, quantitative research covering multiple water quality indicators at the national city level and multiple time dimensions are still lacking.

China, the world’s largest developing country with a large total population20, however, possesses only a quarter of the global average per capita water availability21. The rapid economic development that has occurred in recent decades has inevitably resulted in the exacerbation of water pollution in cities, leading to water crises and diseases that threaten public health22,23. The rivers of China are dominated by oxygen-consuming pollution, i.e., permanganate index (CODMn) and ammonia nitrogen (NH3-N), and a series of corresponding discharge reduction targets have been established24. Despite the achievements of water quality improvement through water pollution control actions in China, the distribution of water quality varies across the country2. Furthermore, a seasonal trend in water quality is observed, with a notable decrease in dissolved oxygen (DO) and increases in CODMn and NH3-N in most basins in summer2,25. Moreover, surface air temperature in China is rising at a rate that exceeds the global average26, necessitating urgent attention to temperature-induced alterations in water quality at the city level over extended time periods.

In this research, we employ fixed effects models to estimate the impacts of air temperatures (i.e., normal and high temperatures, and heatwaves) on water quality in 276 Chinese cities, and analyze heterogeneity by region and season (Fig. 1). To more accurately quantify the net effects of temperature on water quality, control variables such as gross regional product (GDP), amount of wastewater discharge, secondary production output share, and precipitation are included in the models. Furthermore, the contribution of temperature to quality-based water scarcity risks is calculated. The research enables the identification of risk-prone areas vulnerable to water quality degradation or notable water scarcity under the impacts of climate change, providing valuable insights into optimal climate risks and water management policies.

Fig. 1: Flowchart of the research strategies.
figure 1

a Data preparation, including data collection and spatial and temporal scales; b Empirical model development, including data model specification, model selection, heterogeneity analysis, robustness test, and spatial and temporal scales; c Model results, including normal temperature, extreme temperature, and water scarcity risks.

Results and Discussion

Effects of air temperature on water quality

Our findings reveal inverted U-shaped non-linear relationships between daily air temperature and concentrations of DO, CODMn, and NH3-N (Table 1), consistent with previous regional lake dataset validation or experimental and observational studies16,17,27,28. Such consistency across different but related environmental contexts is probably because with rising temperatures, the decomposition of organic and inorganic substances initially lags behind the production, but eventually exceeds it29. Consequently, the marginal effects of temperature shift from positive to negative, leading the total effects to first increase and then decline (Fig. 2). Specifically, the inflection points for the effects of temperature on DO, CODMn, and NH3-N exhibit certain variations, being −4 °C, −2 °C, and −21 °C, respectively (Fig. 2a, c, e). The continuous decline after the inflection threshold is probably caused by the increase in biodegradation activity under higher temperatures30,31, which decomposes CODMn and NH3-N in the river, while consuming oxygen. Furthermore, enhanced volatilization or adsorption of some organic compounds, as well as nitrification, denitrification, and volatilization32 at higher temperatures, contribute to the decreasing trend of CODMn and NH3-N, respectively. In contrast, prior to the threshold, rising temperatures in the lower temperature range facilitate stream primary productivity17,33, potentially increasing DO. While substrate release, solubility of organic compounds, and ammonification34, release of macroinvertebrate excretions35 with rising temperature promote the elevation of CODMn and NH3-N. Interestingly, the total effects are negative while the marginal are positive for DO and CODMn at below −7 °C and −4 °C (Fig. 2b, d), respectively. Gas exchange hindered by ice on the river surface and the low activity of organic compounds at low temperatures may contribute to this result. However, the temperature thresholds in our study vary from previous work16,17,27,28, likely due to differences in hydrology, temperature ranges, and methodology. In addition, biological treatment efficiency of wastewater pollutants before discharge is closely related to the temperature36, which at high levels boosts microbial activity contributing to the removal efficiency.

Fig. 2: Marginal and total effects of temperature on water quality indicators at different time scales.
figure 2

a Marginal and b total effects of temperature on DO; c Marginal and d total effects of temperature on CODMn; e Marginal and f total effects of temperature on NH3-N. The lines represent the nonlinear responses of three water quality indicators to temperature in the study region from 2014 to 2020, evaluated at different temporal scales (colors). The effects were estimated according to Eq. (1). The marginal effects first increase above zero and then decline, while the total effects exhibit an inverted U-shaped response. The shaded areas around the curves indicate the 90% confidence intervals of the estimated temperature effects, with standard errors clustered at the city level.

Table 1 Panel regression results for the effects of daily average temperature

Besides exploring on the daily scale, we further investigate the temperature impacts at longer time scales, including five, ten, and fifteen days and month (Table 2). The inverted U-shaped non-linear effects on DO and CODMn are enhanced at longer time scales in all cases (Fig. 2a–d), while NH3-N is insignificant (Fig. 2e, f). The impacts in different municipalities distribution also show a consistent trend across time scales (Supplementary Figs. 13). The results may be attributed to deeper dynamic processes and environmental changes under temperature variation at larger time scales37, such as biological population turnover38, metabolism39, flow exchange37, and water stratification40. Nevertheless, the resilience of nitrogen microbial activity to short-term surface water exchange and changes in water composition41 may result in insignificant fluctuations with temperature changes. These findings emphasize the importance of different time scales for water management policy design, particularly in light of cumulative impacts of temperature at longer time scales, which are still concerning although currently less pronounced than rainfall or anthropogenic discharges42,43, especially in global warming.

Table 2 Panel regression results of the main models in different temporal scales

We further observe that the temperature and precipitation interactions are significantly positive in the models of DO and NH3-N at the daily scale (Table 1 (1, 3)). As illustrated in Supplementary Fig. 4, at similar higher temperature levels, the concentrations of DO and CODMn in the river rise with increasing precipitation. This phenomenon may be attributed to the capacity of precipitation to transport large amounts of unconsumed oxygen and nutrient inputs into the river on a daily basis44. Therefore, precipitation is also an indispensable factor in assessing climatic influences on water quality13 and should be taken into account when formulating climate change-related response strategies.

Impact heterogeneity of region

As shown in Supplementary Figs. 5 and 6, the Haihe River, as well as the middle and lower reaches of the Yellow River, are distinguished by exceptional water quality concerns, notable temperature fluctuations, and a considerable population density2. Consequently, we have conducted a detailed examination of the pollutant indicators within this region, employing a differentiated approach. The findings indicate that the temperature effects in these regions are consistent with the main results, maintaining an inverted U-shape (Supplementary Fig. 7). Notably, in the 0 ~ 15 °C interval, the effect on CODMn still increases with rising temperatures, while at temperatures above 0 °C, decreases in both CODMn and NH3-N are less pronounced than in the national samples (Supplementary Fig. 7b, d). This underscores the necessity for targeted measures to address oxygen-depleting water pollution under temperature impact in areas with existing water quality issues.

Considering the regional variation in temperature distribution across China, we assess the spatial heterogeneity of temperature impacts (Fig. 3a, b). The data are categorized into four groups: northeastern, eastern, central, and western areas (Supplementary Fig. 8a). We find the quadratic term of temperature coefficients in northeastern region becomes greater than national samples, potentially related to the higher sensitivity of water bodies to temperature difference45 and higher water quality bottom (Supplementary Fig. 6). In the eastern region, the effect of temperature on DO shifts to a negative effect. This is probably attributed to higher generation of anthropogenic pollutants from densely populated area46 and low rate of slow-flowing gas exchange47 caused by the small topographic drop (Supplementary Fig. 5). With more anthropogenic pollutants and low oxygen recharge, higher temperature increases oxygen consumption, resulting in declining DO. Temperature in the central and western regions significantly reduces NH3-N, probably due to large changes in topography, with sufficient oxygen exchange, and enhanced activities of consuming NH3-N microorganisms at higher temperatures.

Fig. 3: Regional heterogeneity analysis of temperature impacts on water quality at 15-day scales.
figure 3

Estimates of the effects of the a linear and b quadratic terms of temperature when dividing the data according to geographic distribution. Estimates of the effects of the c linear and d quadratic terms of temperature when dividing the data according to the Yangtze and Yellow Rivers. The point estimates show the average effects of temperature under different groups, and the error bars represent the 90% confidence interval of the effect. The effects are estimated based on Eq. (1) The estimates reflect how water quality in each region responds to temperature according to the regional classification.

We further investigate the heterogeneity in the Yangtze and Yellow River Basins (Supplementary Fig. 8b), indicating greater and more significant effects in Yangtze River basin than Yellow River basin (Fig. 3c, d). Specifically, the effects on DO and CODMn in Yangtze River Basin turn to negative effects. This can be attributed to the warmer and wetter climate in Yangtze River may enhance active chemical and biological behaviors and lead to more obvious water quality fluctuations.

Impact heterogeneity of season

The annual temperature distribution is characterized by distinct seasonal variations (Supplementary Fig. 9), and we further explore the impact of seasonal effects on water quality (Fig. 4). During summer, the influence on DO is predominantly negative and may be related to high water temperature within the season. In the other seasons, the effects reduce probably because of relatively flat temperature fluctuations, which serve to diminish the DO variations.

Fig. 4: Seasonal heterogeneity analysis of temperature impacts on water quality at 15-day scales.
figure 4

a Estimates of impacts by the temperature linear term and b quadratic term when dividing the data by season. The point estimates show the average effects of temperature under different groups, and the error bars represent the 90% confidence interval of the effect. The effects were estimated based on Eq. (1). The estimates reflect how water quality in each season responds to temperature according to the seasonal classification.

In winter, CODMn concentration increases with rising temperature, which can be attributed to weaker biological activity under colder water temperature, impeding the timely decomposition of organic pollutants48. Additionally, lower runoff volume during winter ultimately leads to a higher CODMn concentration. The inverted U-shaped effects are most pronounced in the spring and autumn, when temperature fluctuations are most noticeable, and they enhance the rates of dissolution and decomposition of water pollutants. The effects of temperature on NH3-N are significant mainly in spring and autumn, with a significant linear negative pattern in spring and an enhanced inverted U-shaped response in autumn. This may be related to the relatively higher temperature in spring and autumn, increasing the vitality of biological activities49.

Robustness tests

We conduct several robustness tests to verify the observed effects of air temperature on water quality. We first expand the time scale of the data to the seasonal scale to ensure the suitability of the model at a larger time scale to validate the main model of this study (Supplementary Table 3). Secondly, we replace the independent variables with daily maximum and minimum temperature on the daily scale model to ensure the wide application and prevent the contingency of the independent variables (Supplementary Table 4). Thirdly, we introduce seasonal fixed effects to control for seasonal disturbances in water quality, further testing the robustness of time fixed effects (Supplementary Table 5). Fourthly, we determine robustness to remove the insignificant interaction term between precipitation and temperature on the monthly scale (Supplementary Table 6). Finally, we validate our main findings by downscaling the data to the monitoring section level, thereby confirming the model’s applicability at a finer spatial scale (Supplementary Table 7). Across these tests, the effects of temperature are consistent with the results of the main model, indicating the robustness of the model in this study.

Results of extreme heat temperature

The quality of water subjected to elevated temperatures for extended periods may undergo substantial alterations from its typical patterns, potentially resulting in long-term deterioration50. We apply the daily maximum temperature above 35 °C to explore the effects of extreme temperature. It is notable that the response of CODMn shifts to a positive U-shape and subsequently increases above 37 °C, suggesting high temperature can contribute to the deterioration of water quality (Supplementary Table 8 and Fig. 5). This is associated with reduced stream flow9, a higher solubility of organic matter51, and inhibition or inactivation of biological enzymes involved in the degradation of organic compounds52,53 under high temperature conditions. High temperature has little effect on DO and NH3-N, potentially because of the low levels of DO in the river and the limitation of conversion reactions associated with NH3-N in high temperature interval54.

Fig. 5: Effects of single-day high temperature on CODMn.
figure 5

a Marginal and b total effects of single-day high temperature on CODMn. The lines represent the nonlinear response of CODMn to temperature in the study area from 2014 to 2020. The effects were estimated based on Eq. (1). The marginal effect is initially negative and then becomes positive, while the total effect exhibits a U-shaped pattern. The starting and ending points of each curve correspond to the historical range of daily maximum temperatures above 35 °C across all cities from 2014 to 2020. The shaded area around each curve represents the 90% confidence interval of the estimated temperature effect, with standard errors clustered by city. Full regression results are shown in Supplementary Table 8.

Furthermore, an investigation into the effects of heatwaves is conducted based on a single day of high temperatures exceeding 35 °C, with the duration of the heatwaves lasting for two, three, and four days (Supplementary Table 9). The effect of extreme high temperature on CODMn is significant and exhibits a positive U-shaped relationship across the three scenarios. When exceeding 35 °C for two and four consecutive days, the concentration of CODMn increases by 9% and 10%, respectively. Rapid algal and phytoplankton blooms and metabolic die-offs under continuous high temperatures may result in higher organic matter concentrations9. Although DO and NH₃-N show weak responses under extreme temperatures, other parameters such as salinity, algae, and nutrients are also often highly correlated with CODMn55,56,57. Consequently, these indicators are likely to exhibit elevated concentration, and patterns have been demonstrated in previous studies9,14. Therefore, it is necessary to further confirm the effects of extreme temperature scenarios with available water quality data in the future, proposing strategies to strengthen ecosystem resilience and adaptive management for high-temperature stress.

Quality-based water scarcity risks under extreme temperatures

As illustrated in Section Results of extreme heat temperature, the occurrence of extreme temperatures has been observed to result in an increase in CODMn concentrations, thereby further exacerbating the risk of water scarcity driven by temperature under local water pollution risks (Supplementary Note 1 and Supplementary Fig. 10). We screen the samples with increased concentration caused by extreme temperatures and calculate total water scarcity risk induced by CODMn (Eq. (5)). Most of the municipalities in the sample (such as Hangzhou and Nanchang cities) are not at risk of quality-based water scarcity under extreme temperature, but we also capture areas that are relatively highly affected (Fig. 6). For single-day high temperature, cities such as Jiaxing, Zhumadian, Shangqiu, Zhoukou, Fuyang, Hefei, and Wuhu are exposed to CODMn-induced quality-based water scarcity risks, with the contribution of temperature exceeding 67% (i.e., the contribution of temperature to CODMn-induced risk (Eq. (6)) divided by total CODMn-induced risk (Eq. (5)) (Fig. 6a). The heat wave scenario (four consecutive days above 35 °C) is essentially similar to the high temperature scenario, with the highest risk of water scarcity in Huaibei, followed by Shangqiu, which face additional water scarcity risk of 0.12 and 0.02 (WSquality-hw), respectively (Fig. 6b). This means that the heatwave-driven elevation of CODMn requires the city to obtain additional 12% and 2% of available water withdrawals, respectively, to satisfy the water demand of the sector. Therefore, despite the relatively small number of risk samples captured currently, the potential contribution to quality-based water scarcity risk in future scenarios with extreme temperature events cannot be ignored. Our findings show a city is at water scarcity risk while the surroundings are not, which may be attributed to the low multi-year city’s water quality baseline (Supplementary Fig. 6). Furthermore, the results are also affected by the limitations posed by the absence of municipal water use data, which represents a challenge for subsequent studies to overcome.

Fig. 6: Water scarcity risks induced by water quality of city for high-temperature and heat wave of CODMn samples.
figure 6

a Risks for single-day high-temperature city samples. b Risks for heat wave city samples. WSquality (All) refers to quality-based water scarcity induced by CODMn and NH3-N, and WSquality (CODMn) refers to quality-based water scarcity induced by CODMn. WSquality-temp (CODMn) represents the contribution of temperature to quality-based water scarcity induced by CODMn. WSquality-hw (CODMn) represents the contribution of heatwave to quality-based water scarcity induced by CODMn. A scarcity risk value represents the proportion of additional water withdrawals required when water quality degradation under extreme temperature renders part of the sectoral water supply inapplicable.

Conclusion

Our findings quantify the impacts of air temperature on water quality, thereby providing valuable insights for decision makers to design evidence-based strategies regarding the management of river environments in climate change mitigation under current scenarios. This study is, to the best of our knowledge, the first to analyze the contemporary responses of Chinese municipal river water quality to temperature at a national scale and integrates with quality-based water scarcity assessment to yield three critical findings. Firstly, DO, CODMn, and NH3-N exhibit inverted U-shaped responses to air temperature across various time scales (i.e., day, 5-day, 10-day, 15-day, and month), with impacts gradually expanding with the larger time scales. Secondly, temperatures above 37°C for a single day and heatwaves exceeding 35°C for two and four consecutive days can significantly elevate CODMn concentrations in rivers. Finally, an increase in CODMn induced by single-day high temperature and heatwaves contributes to the quality-based water scarcity related to CODMn at a high level, with above 67% and 10%, respectively.

This work also highlights key hotspots and provides policymakers with temperature-related baseline insights for optimizing water quality management strategies. In southern China, rising temperatures have a more pronounced negative impact on DO. Regions with poor water quality, as well as the Northeast and the Yangtze River Basin, are particularly vulnerable to the adverse effects of normal temperature. To ensure the long-term sustainability of river ecosystems under rising temperatures, it is imperative to enhance the efficiency of water quality monitoring and governance through more effective pollutant control, adaptive water management, and risk mitigation strategies. Cities such as Shangqiu, Huaibei and Wuhu should emphasize the contribution of temperature to the risk of quality-based water scarcity, and make timely adjustments to water withdrawals to guarantee the smooth operation of production and living conditions. Therefore, empirically-based national-scale impact identification and prediction are essential to inform policies aimed at achieving sustainable development. However, this study did not incorporate interactions between surface water and groundwater, the mediation effects among water quality indicators, or potential estimation biases arising from uncertain water withdrawal locations, which could be further examined in subsequent studies.

Methods

Climate data

The meteorological data used in this study is the fifth generation ECMWF atmospheric reanalysis of the global climate (ERA5) reanalysis dataset58. We use daily 2-meter mean air temperature for the 2014–2020 historical period, with total daily precipitation as a control variable. The data are collected at 0.25° × 0.25° grid on the daily scale, and are spatially merged according to the boundaries of municipalities to reflect the city temperature levels. To capture the effects’ variations of different time scales, we merge the data at the five-day, ten-day, fifteen-day, and monthly scales. We also include daily maximum temperatures in the study to further analyze the impacts of extreme temperatures.

We use precipitation as a control variable because it can form surface runoff, flushing pollutants from construction land and farmland into the water bodies43. Moreover, under climate change, temperature and rainfall are strongly correlated, and changes in temperature tend to alter rainfall59. Thus, to further understand the interactive effects of meteorological features on water quality, we include the interaction between temperature and precipitation. Descriptions of study area and the main variables are specified in the Supplementary Note 2 and Supplementary Figs. 6 and 11.

Water quality data

DO, CODMn, and NH3-N are the main water quality indicators employed in this study. DO serves as a critical indicator of aquatic ecosystem functioning, reflecting biogeochemical processes including biological respiration and photosynthesis in water bodies17. CODMn represents the level of reducing organic pollution caused by eutrophication in aquatic systems60. NH3-N is one of the most important indicators for evaluating nitrogen pollution in water bodies, which also reflects the level of eutrophication61. The water quality data is obtained from the National Environmental Monitoring Centre of China (http://www.cnemc.cn/sssj/) in the form of 4-hourly cross-sectional monitoring data and combined by applying the arithmetic mean from each monitoring station across the city62,63. Descriptions of the distribution of multi-year water quality conditions are specified in the Supplementary Note 3 and Supplementary Figs. 6 and 12.

Socio-economic data

Given that river water quality and climate conditions are both influenced by human activities, we select various socio-economic variables as control variables, and the descriptions of impacts are specified in Supplementary Note 4. To ascertain the net effects of temperature on water quality, a number of variables are obtained from the China Urban Statistical Yearbook. These include GDP of each industry, wastewater discharge (including domestic and industrial wastewater), nitrogen fertilizer application, and pipeline lengths.

Additionally, inadequate water quality can pose a critical constraint on water availability2. In order to assess the quality-based water scarcity, data on agricultural, industrial, and domestic water usage in prefecture-level cities is collected from provincial water resources bulletins. Total water resources data is obtained from the Statistical Yearbook of China. Nevertheless, the data are insufficient in quantities due to the disparate publication of provincial documents, varying statistical formats, and the loss of documents in the bulletins. Thus, to reflect the national situation, we also collect data on water use and total water resources from the annual China Water Resources Bulletin at the provincial level.

Main models

We employ fixed effects panel regression models to estimate the effects of air temperature on water quality. The models, including city and time (i.e., day, 5-day, 10-day, 15-day, and month) fixed effects, can be effectively applied to strengthen causal effects assessment by adjusting for unobserved unit-specific and time-specific confounders64,65. The main model specification of this study is shown in Eq. (1), involving the primary and quadratic terms of temperature, the interaction term between temperature and precipitation, and various control variables. We logarithmize the water quality indicators because of their highly skewed distribution (Supplementary Fig. 13). The t-statistic tests whether a coefficient of each independent variable significantly differs from zero, and the corresponding p-value determines if the null hypothesis can be rejected.

$${{\mathrm{ln}}}{{{{\rm{WQ}}}}}_{{{{\rm{i}}}},{{{\rm{t}}}}}= \,{\beta }_{1}{\overline{{{{\rm{Temp}}}}}}_{i,t}+{\beta }_{2}{\overline{{{{\rm{Temp}}}}}}_{i,t}^{2}+{\beta }_{3}{\overline{{{{\rm{Temp}}}}}}_{{{{\rm{i}}}},{{{\rm{t}}}}}\times {{{{\rm{Prec}}}}}_{i,t}+{\eta }_{1}{{{{\rm{GDP}}}}}_{i,t}\\ +{\eta }_{2}{{{{\rm{Industry}}}}}_{i,t}+{\eta }_{3}{{{{\rm{Emission}}}}}_{i,t}+{\eta }_{4}{{{{\rm{Prec}}}}}_{i,t}+{\alpha }_{i}+{\gamma }_{t}+{\varepsilon }_{i,t}$$
(1)

where \({{{{\rm{WQ}}}}}_{i,t}\) represents the concentrations of water quality indicators (mg/L) of city \(i\) on day \(t\), including DO, CODMn, and NH3-N. \({\overline{{{{\rm{Temp}}}}}}_{i,t}\) is the average temperature value (°C) of city \(i\) on day \(t\). \({{{{\rm{GDP}}}}}_{i,t}\), \({{{{\rm{Industry}}}}}_{i,t}\), and \({{{{\rm{Emission}}}}}_{i,t}\) represent the total GDP, secondary sector output share, and amount of wastewater discharge of city \(i\) on day \(t\) in the corresponding year, respectively. \({{{{\rm{Prec}}}}}_{i,t}\) indicates the total precipitation (m) of \(i\) on day \(t\). \({\alpha }_{i}\) and \({\gamma }_{t}\) are used as regional and daily fixed effects, respectively. \({\varepsilon }_{i,t}\) is the city-time error. Standard errors are clustered in cities.

In addition, we perform spatial spillover effects of water quality indicators, regional and seasonal heterogeneity analyses, as well as robustness tests, as described in the Supplementary Notes 57.

Empirical modeling of extreme temperatures

Given that temperature-related extreme event scenarios, such as high temperature and heatwaves, can cause more complex system responses in river water bodies9,66, we screen out the samples for separate analysis. We define single-day high temperature as the maximum temperature \(\tt {Tem}{p}_{{Max}35}\) of city \(i\) exceeding 35 °C on day \(t\), and this threshold has been adopted widely in previous studies67,68,69. We construct and compare multiple models (Supplementary Note 8), and ultimately the model specification for single-day high temperature is shown in Eq. (2).

$${{{\mathrm{ln}}}}{{{{\rm{WQ}}}}}_{i,t}= \; {\beta }_{1}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}+{\beta }_{2}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}^{2}\\ +{\beta }_{3}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}\times {{{{\rm{Fertilizer}}}}}_{i,t}+{\eta }_{1}{{{{\rm{GDP}}}}}_{i,t}+{\eta }_{2}{{{{\rm{Fertilizer}}}}}_{i,t}\\ +{\eta }_{3}{{{{\rm{Agriculture}}}}}_{i,t}+{\eta }_{4}{{{{\rm{Industry}}}}}_{i,t}+{\eta }_{5}{{{{\rm{Pipe}}}}}_{i,t}+{\alpha }_{i}+{\gamma }_{t}+{\varepsilon }_{i,t}$$
(2)

where \({{{{\rm{Fertilizer}}}}}_{i,t}\), \({{{{\rm{Agriculture}}}}}_{i,t}\) and \({{{{\rm{Pipe}}}}}_{i,t}\) represent the amount of nitrogen fertilizer applied, primary sector output share, and drainage pipe length of city \(i\) on day \(t\) in the corresponding year, respectively.

We further investigate the impacts of heatwave events on water quality, which represent a prolonged period of hot weather, spanning several days to weeks70. A heat wave involves both the intensity and persistence of high temperatures, and is therefore defined as in which the daily maximum temperature in a city \(i\) exceeds 35 °C for two, three, or four consecutive days67,71. Thus, the heat wave variable \({{{{\rm{H}}}}{{{\rm{eatwave}}}}}_{i,t}\) is set as a binary variable, equal to 1 if the above definition is met and 0 otherwise (see Eq. (3)). \({{{{\rm{H}}}}{{{\rm{eatwave}}}}}_{i,t}\) is added to the single-day high temperature model, as shown in Eq. (3).

$${{{\mathrm{ln}}}}{{{{\rm{WQ}}}}}_{i,t}= \; {\beta }_{1}{{{{\rm{H}}}}{{{\rm{eatwave}}}}}_{i,t}+{\eta }_{1}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}+{\eta }_{2}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}^{2}\\ +{\eta }_{3}{{{{\rm{Tem}}}}{{{{\rm{p}}}}}_{{{{\rm{Max}}}}35}}_{i,t}\times {{{{\rm{Fertilizer}}}}}_{i,t}+{\eta }_{4}{{{{\rm{GDP}}}}}_{i,t}+{\eta }_{5}{{{{\rm{Fertilizer}}}}}_{i,t}\\ +{\eta }_{6}{{{{\rm{Agriculture}}}}}_{i,t}+{\eta }_{7}{{{{\rm{Industry}}}}}_{i,t}+{\eta }_{8}{{{{\rm{Pipe}}}}}_{i,t}+{\alpha }_{i}+{\gamma }_{t}+{\varepsilon }_{i,t}$$
(3)

Quality-based water scarcity risk calculation

Water quality requirements depend on the intended use72, and therefore variations in water quality in a watershed can affect regional water use in the agricultural, industrial, and domestic sectors2. Specific city water quality requirements are described in Supplementary Note 1. Quality-based water scarcity risk is calculated as the ratio of the amount of water required for dilution to achieve adequate water quality to the amount of water available for use2, as shown in Eqs. (4) and (5). To capture the contribution of temperature to quality-based water scarcity risk, we further calculate the total effect of temperature on concentration contribution, as shown in Eq. (6).

$${{dq}}_{j}=\left\{{\left(\frac{{{{{\rm{D}}}}}_{j}* {{{{\rm{C}}}}}_{a}}{{{{\rm{Cma}}}}{{{{\rm{x}}}}}_{a,j}}-{{{{\rm{D}}}}}_{j}\right)}_{\begin{array}{cc}, & {{{{\rm{C}}}}}_{a} > \end{array}{{{\rm{C}}}}{\max }_{a,j}}^{\begin{array}{cc}0, & {{{{\rm{C}}}}}_{a}\end{array}\le {{{\rm{C}}}}{\max }_{a,j}}\right.$$
(4)
$${{{{\rm{WS}}}}}_{{{{\rm{quality}}}}}=\frac{\mathop{\sum }_{j}{{{{\rm{dq}}}}}_{j}}{{{{\rm{Q}}}}-{{{\rm{EFR}}}}}$$
(5)
$${{{{\rm{WS}}}}}_{{{{\rm{temp}}}}}=\frac{{{{{\rm{C}}}}}_{{temp},a}}{{{{{\rm{C}}}}}_{a}}\times {{{{\rm{WS}}}}}_{{{{\rm{quality}}}}}$$
(6)

where \({{{{\rm{dq}}}}}_{j}\) represents the additional amount of dilution required by sector \(j\) to obtain acceptable water quality, and \({{{{\rm{D}}}}}_{j}\) is the amount of water withdrawn of sector \(j\). \({{{{\rm{C}}}}}_{a}\) is the actual concentration level of water quality parameter \(a\). \({{{{\rm{C}}}}\max }_{a,j}\) indicates the maximum threshold value of the water-using sector \(j\) of parameter \(a\). \({{{{\rm{WS}}}}}_{{{{\rm{quality}}}}}\) is quality-based water scarcity, and \({{{\rm{Q}}}}\) is the total water resources of city \(i\), including surface runoff and precipitation infiltration recharge. \({{{\rm{EFR}}}}\) is the Environmental Flow Requirement, which is defined as 80% of the water availability according to the previous study2. The remaining 20% can be considered blue water available for human use without compromising the integrity of water-dependent ecosystems and livelihoods downstream. \({{{\rm{Q}}}}-{{{\rm{EFR}}}}\) represents the amount of available water withdrawals for a city. \({{{{\rm{WS}}}}}_{{{{\rm{temp}}}}}\) and \({{{{\rm{C}}}}}_{{temp},a}\) indicate the contribution of temperature to \({{{{\rm{WS}}}}}_{{{{\rm{quality}}}}}\) and the concentration of parameter \(a\).

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.