River and lake index ammonia nitrogen monitoring method, device and system and storage medium

By integrating a self-attention enhanced hybrid density network (ESA-MDN), the problems of low frequency, sparse coverage and insufficient reliability in ammonia nitrogen monitoring of rivers and lakes are solved, and high-precision, real-time ammonia nitrogen concentration inversion and uncertainty quantification are achieved, which is suitable for monitoring complex urban water bodies.

CN121933447APending Publication Date: 2026-04-28EAST CHINA NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
EAST CHINA NORMAL UNIV
Filing Date
2026-02-09
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing technologies for monitoring ammonia nitrogen in rivers and lakes suffer from low monitoring frequency, sparse spatial coverage, and delayed response, making it difficult to meet the needs of refined and dynamic management of complex water systems. Furthermore, existing remote sensing models lack reliability in urban waterways, cannot quantify and predict uncertainties, and traditional network structures have limited ability to model spectral interaction relationships.

Method used

An integrated self-attention enhanced hybrid density network (ESA-MDN) is adopted to dynamically weight the dependencies between key bands through a self-attention mechanism, combined with a regularized hybrid density loss function, to achieve efficient inversion and uncertainty prediction of ammonia nitrogen concentration.

Benefits of technology

It improves the accuracy of ammonia nitrogen inversion, provides a reliable confidence interval, enhances the robustness and generalization ability of the model in complex urban water bodies, enables high-frequency monitoring and real-time response, and solves the limitations of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121933447A_ABST
    Figure CN121933447A_ABST
Patent Text Reader

Abstract

The invention discloses a river and lake index ammonia nitrogen monitoring method and device, a system and a storage medium, an ESA-MDN (self-attention enhanced mixed density network) is integrated, a dependency relationship between key wavebands is dynamically weighted through a self-attention mechanism, and multi-source uncertainty prediction is fused in combination with an integration strategy. By adopting the technical scheme of the invention, the ammonia nitrogen inversion precision is improved, a reliable confidence interval is provided, and the robustness and generalization ability of the model in a complex urban water body are remarkably enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of ecological monitoring technology, specifically relating to a method, device, system, and storage medium for monitoring ammonia nitrogen in rivers and lakes. Background Technology

[0002] With the acceleration of urbanization and the intensive development of agriculture in my country, nitrogen pollutant emissions have continued to increase, and nitrogen pollution in water bodies has become increasingly prominent. Ammonia nitrogen (NH3-N), as a key intermediate form in the nitrogen cycle, has become a significant factor affecting the safety of river and lake water quality and the health of ecosystems. Ammonia nitrogen mainly originates from insufficiently treated domestic sewage (containing high concentrations of nitrogenous organic matter), wastewater from large-scale livestock and poultry farming, fertilizer runoff from farmland, and industrial emissions from food processing, chemical, and pharmaceutical industries. In the aquatic environment, ammonia nitrogen exists in two forms: free ammonia (NH3) and ammonium ions (NH4⁺), with their ratio regulated by pH and water temperature. Free ammonia is highly toxic; even at low concentrations (>0.1 mg / L), it can cause acute or chronic poisoning to fish, plankton, and benthic organisms, inhibiting their growth and reproduction and even leading to death, severely disrupting the aquatic food chain structure and ecological functions. More seriously, ammonia nitrogen is one of the key driving factors in the evolution of eutrophication in water bodies. Under aerobic conditions, ammonia nitrogen can be converted into nitrite (NO2⁻) and nitrate (NO3⁻) through nitrification. The latter provides a nitrogen source for algal growth, promoting the proliferation of cyanobacteria and green algae, leading to algal blooms or red tides. Under hypoxic conditions, ammonia nitrogen accumulation exacerbates the black and odorous phenomenon in water bodies, significantly reducing the sensory quality and usability of the water. Furthermore, if ammonia nitrogen levels in drinking water sources exceed standards, it not only increases the cost of water treatment at water plants (requiring enhanced biological pretreatment or breakpoint chlorination), but may also react with organic matter during disinfection to generate chloramine byproducts with carcinogenic risks, threatening public drinking water safety. Given its environmental and health risks, my country's "Surface Water Environmental Quality Standard" (GB 3838–2002) lists ammonia nitrogen as a mandatory monitoring indicator, classifying it into five categories based on water body function, and setting strict limits from Class I (≤0.15 mg / L) to worse than Class V (>2.0 mg / L). In recent years, the Ministry of Ecology and Environment has also included ammonia nitrogen in the total amount control system for key pollutants, and has clearly put forward the governance requirements of "accurately identifying the sources of ammonia nitrogen pollution, strengthening process supervision, and improving monitoring and early warning capabilities".

[0003] However, current ammonia nitrogen monitoring in rivers and lakes still heavily relies on manual point sampling and laboratory chemical analysis methods (such as Nessler's reagent spectrophotometry and salicylic acid method), which have significant shortcomings: First, the monitoring frequency is low (usually monthly or quarterly), making it difficult to capture short-term concentration fluctuations caused by rainfall runoff and sewage discharge fluctuations; second, the spatial coverage is sparse, failing to reflect the pollution heterogeneity of complex water systems such as urban river networks and tributary ditches; and third, the response is delayed, making it difficult to support rapid source tracing and emergency response to sudden pollution events. Especially in high-density urban clusters such as the Yangtze River Delta and the Pearl River Delta, where river networks are dense, pollution sources are dispersed, and hydrodynamic conditions are complex, traditional monitoring methods are no longer sufficient to meet the needs of refined and dynamic management.

[0004] Against this backdrop, remote sensing technology offers a new approach to monitoring ammonia nitrogen in rivers and lakes, overcoming traditional limitations. Leveraging its advantages of wide coverage, high timeliness, non-contact operation, and repeatable observation, remote sensing can efficiently capture the spatial distribution and dynamic changes of ammonia nitrogen in complex water systems, making it particularly suitable for densely populated urban areas and tributary ditches where ground-based monitoring stations are difficult to deploy. By integrating UAV multispectral / hyperspectral imagery with machine learning models, ammonia nitrogen concentrations over large areas of water can be retrieved without extensive on-site sampling, significantly improving the spatiotemporal resolution and response speed of monitoring. This not only helps reveal pollution hotspots and migration patterns but also lays the foundation for building an intelligent water quality monitoring system that integrates air and ground monitoring.

[0005] Currently, scholars both domestically and internationally have conducted extensive research in the field of remote sensing water quality inversion, primarily employing methods such as Support Vector Machines (SVM), Random Forests (RF), and Deep Neural Networks (DNN) to establish the mapping relationship between spectral reflectance and ammonia nitrogen concentration. However, existing models generally suffer from two major limitations: first, most methods only output point estimates, failing to quantify prediction uncertainties and exhibiting insufficient reliability in urban waterways with drastic water quality fluctuations; second, traditional network structures have limited ability to model nonlinear interactions between multispectral bands, especially prone to losing key features in low-correlation but high-information band combinations. In recent years, Mixed Density Networks (MDNs) have been introduced into environmental inversion tasks due to their ability to output probability distributions, but their ability to capture complex spectral dependencies remains insufficient. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides a method, device, system, and storage medium for monitoring ammonia nitrogen in rivers and lakes.

[0007] To achieve the above objectives, the present invention provides the following solution: A method for monitoring ammonia nitrogen in rivers and lakes includes: Acquire UAV multispectral image data of sampling points; Multispectral image data is preprocessed to obtain surface reflectance data of sampling points; Surface reflectance data is input into an integrated self-attention enhanced hybrid density network to generate a spatial distribution map of ammonia nitrogen concentration at the sampling points. The regularized hybrid density loss function used in the self-attention enhanced hybrid density network organically combines negative log-likelihood loss, entropy regularization term and variance constraint term.

[0008] As a preferred method, preprocessing of multispectral image data includes: sensor radiometric calibration, geometric correction, image stitching, reflectivity conversion, and selection and modeling of characteristic bands.

[0009] As a preferred approach, an effective band selection method was employed to identify the bands most relevant to water quality parameters, and the bands used for modeling were determined as follows: 1=

[0010] 2=

[0011] 3=

[0012] 4=

[0013] 5=

[0014] Among them, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which i =1,2,3,4,5 correspond to the surface reflectance of five specific wavebands: r 1: Reflectivity of the blue light band with a center wavelength of 450 nm; r 2: Reflectivity in the green light band with a center wavelength of 555 nm; r 3: Reflectivity in the red light band with a center wavelength of 660 nm; r 4: Reflectivity of the red-edge band with a center wavelength of 720 nm; r 5: Near-infrared reflectance with a center wavelength of 840 nm.

[0015] The present invention also provides a river and lake ammonia nitrogen monitoring device, comprising: The first processing module is used to acquire UAV multispectral image data of the sampling points; The second processing module is used to preprocess the multispectral image data to obtain the surface reflectance data of the sampling points; The third processing module is used to input surface reflectance data into the integrated self-attention enhanced hybrid density network to generate a spatial distribution map of ammonia nitrogen concentration at the sampling points. The self-attention enhanced hybrid density network uses a regularized hybrid density loss function that organically combines negative log-likelihood loss, entropy regularization term and variance constraint term.

[0016] Preferably, the second processing module performs preprocessing on the multispectral image data, including: sensor radiometric calibration, geometric correction, image stitching, reflectivity conversion, and characteristic band selection and modeling.

[0017] As a preferred option, the second processing module employs an effective band selection method to identify the bands most relevant to water quality parameters, determining the bands to be used for modeling as follows: 1=

[0018] 2=

[0019] 3=

[0020] 4=

[0021] 5=

[0022] Among them, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which i =1,2,3,4,5 correspond to the surface reflectance of five specific wavebands: r 1: Reflectivity of the blue light band with a center wavelength of 450 nm; r 2: Reflectivity in the green light band with a center wavelength of 555 nm; r 3: Reflectivity in the red light band with a center wavelength of 660 nm; r 4: Reflectivity of the red-edge band with a center wavelength of 720 nm; r 5: Near-infrared reflectance with a center wavelength of 840 nm.

[0023] The present invention also provides a river and lake ammonia nitrogen monitoring system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a river and lake ammonia nitrogen monitoring method when executed by the processor.

[0024] The present invention also provides a storage medium storing a computer program, which executes a method for monitoring ammonia nitrogen in rivers and lakes when running.

[0025] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention proposes an Ensemble Self-Attention Enhanced Mixture Density Network (ESA-MDN), which dynamically weights the dependencies between key bands through a self-attention mechanism and combines an ensemble strategy to fuse multi-source uncertainty predictions. This not only improves the accuracy of ammonia nitrogen inversion but also provides a reliable confidence interval, significantly enhancing the robustness and generalization ability of the model in complex urban water bodies. Attached Figure Description

[0026] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 This is a flowchart of the ammonia nitrogen monitoring method for rivers and lakes according to an embodiment of the present invention; Figure 2 The image shows the spatial distribution map of ammonia nitrogen concentration generated based on UAV multispectral remote sensing inversion. Detailed Implementation

[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0029] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0030] Example 1 like Figure 1 As shown, this invention provides a method for monitoring ammonia nitrogen in rivers and lakes, comprising: Step 1: Data Acquisition (1) UAV data acquisition This invention utilizes the DJI M300 RTK drone as a flight platform, integrating the Changguang Yuchen AQ600 Pro multispectral imaging system to perform remote sensing aerial photography missions over target river sections, acquiring high-quality multispectral image data. This drone platform boasts excellent wind resistance and payload capacity (maximum payload up to 2.7 kg), stably carrying professional-grade sensors such as the AQ600 Pro, ensuring long-term, high-precision operation. The AQ600 Pro multispectral camera is equipped with five spectral bands for simultaneous exposure, with the following parameters: blue band (450 ± 15 nm), green band (555 ± 13.5 nm), red band (660 ± 11 nm), red-edge band (720 ± 5 nm), and near-infrared band (840 ± 15 nm). Its optical system has a field of view of 48.8° (horizontal) × 37.5° (vertical), which can achieve sub-meter ground resolution at typical flight altitudes, balancing coverage efficiency and detail capture capabilities, and providing a reliable spectral and spatial information basis for subsequent water quality parameter inversion.

[0031] (2) Acquisition of surface water quality sampling data To achieve accurate matching of air-to-ground data, this invention employs a collaborative operation mode of UAV multispectral aerial surveying and synchronous ground sampling. Within the study area, based on the spatial heterogeneity of the water body, 29 representative ground sampling points were deployed. During sampling, a 30 cm diameter water sampler was used to collect samples at a depth of 20 cm below the water surface. Each sampling covered a circular area with a radius of 35 cm centered on the sampling point, and the sampling was repeated five times at the same location. The collected water samples were then combined in a single container and thoroughly mixed to form a 3 L representative mixed water sample for laboratory analysis. All water samples were immediately transferred to opaque brown glass bottles, sealed, and labeled with a unique identifier. They were then stored in a low-temperature insulated box to minimize water quality changes caused by light, temperature, and other factors, ensuring the authenticity and reliability of the test results. The geographic coordinates of each sampling point were determined in real-time using a high-precision GNSS receiver, recording latitude and longitude information with centimeter-level accuracy to ensure precise spatial correspondence with UAV image pixels. This sampling strictly followed the technical specifications of the "GB 3838–2002 Surface Water Environmental Quality Standard", focusing on quantitative analysis of ammonia nitrogen (NH3-N) concentration in the water.

[0032] Step 2: UAV Data Preprocessing To obtain surface reflectance data that can be used for water quality inversion, the raw UAV multispectral imagery needs to undergo a systematic preprocessing process, including sensor radiometric calibration, geometric correction, image stitching, and reflectance conversion.

[0033] (1) Sensor calibration Since the raw data output by the camera is a dimensionless numerical value (DN value), it needs to be converted into radiance with physical meaning. This invention uses a combination of laboratory calibration and field reference plates to achieve radiometric calibration. Before each flight operation, a standard grayscale reflectance reference plate certified by the national metrology authority (with known standard reflectance for each band) is used. R The reference plate was deployed in an open and flat area of ​​the survey zone. After the flight, the average DN value of the corresponding area of ​​the reference plate was extracted from the multispectral image, and converted into radiance by combining it with metadata such as camera exposure time and gain. L (Unit: W·m⁻²·sr⁻¹·μm⁻¹). By establishing R and L The linear relationship is used to determine the calibration coefficients for each band.

[0034] (2) Geometric correction The center position and attitude angle of each image were recorded using a high-precision GNSS / IMU system mounted on a UAV, and spatial registration was performed using ground control points (GCPs) to eliminate geometric distortions caused by platform jitter, lens distortion, and terrain undulations. The spatial positioning accuracy of the corrected images is better than 0.1 m, meeting the requirements for subsequent pixel-level analysis.

[0035] (3) Image stitching A mosaicking algorithm based on feature matching and bundle adjustment was used to fuse single-scene images to generate a seamless multispectral orthophoto covering the entire study area. Color homogenization was performed simultaneously during the mosaicking process to reduce spectral differences caused by uneven illumination and edge effects, ensuring consistent reflectance across the entire image.

[0036] (4) Calculation of surface reflectance For the five bands (blue, green, red, red edge, and near-infrared) of the AQ600 Pro camera, the following linear calibration models are established respectively: r i = a i L i + b i ( i =1,2,3,4,5) in, r i For the first iSurface reflectance of the band, L i This represents the radiance value for the corresponding wavelength band. a i and b i These are the gain and offset coefficients obtained through calibration using a reference plate. This method effectively eliminates the influence of solar incidence angle, atmospheric conditions, and sensor response fluctuations, ultimately generating a physically comparable surface reflectance dataset, providing reliable input for subsequent remote sensing inversion of ammonia nitrogen concentration.

[0037] (5) Acquisition of spectral reflectance at ammonia nitrogen sampling points To obtain spectral information that strictly corresponds to the measured ground-based ammonia nitrogen data, it is necessary to extract the spectral reflectance values ​​of each sampling point from the preprocessed UAV multispectral reflectance image. The specific steps are as follows: The high-precision GNSS measured latitude and longitude coordinates (WGS-84) of the 29 sampling points are transformed to a projection coordinate system consistent with the orthophoto image; the reflectance at the corresponding location of each sampling point is extracted as the representative spectral feature vector for that sampling point. Finally, a set of five-dimensional reflectance data is obtained for each sampling point. r blue, r green, r red r rededge r The data were paired one-to-one with the synchronously acquired measured values ​​of ammonia nitrogen (NH3-N) concentration to form the basic sample set for model training and validation. This process ensures strict alignment of air-to-ground data in both time and space, providing high-quality input for subsequent machine learning inversion.

[0038] Step 3: Feature Band Selection and Modeling In remote sensing water quality inversion, band selection is fundamental to constructing an accurate inversion model. Due to the complex optical properties of water bodies, different water quality parameters exhibit significant differences in their response to spectral wavelengths. Furthermore, multiple bands captured by multispectral or hyperspectral sensors may introduce redundant information, which not only increases the computational burden on the model but may also introduce noise, reducing the model's adaptability and predictive ability. Therefore, employing effective band selection methods to accurately identify the bands most relevant to water quality parameters is crucial for improving model accuracy. After extensive experimentation, this invention has determined the following bands for modeling: 1=

[0039] 2=

[0040] 3=

[0041] 4=

[0042] 5=

[0043] In the above model, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which i =1,2,3,4,5 correspond to the surface reflectance of five specific wavebands: r 1: Reflectivity of blue light at a center wavelength of 450 nm (bandwidth ±15 nm); r 2: Reflectivity of the green light band with a center wavelength of 555 nm (bandwidth ±13.5 nm); r 3: Reflectivity of the red light band with a center wavelength of 660 nm (bandwidth ±11 nm); r 4: Reflectivity of the red-edge band with a center wavelength of 720 nm (bandwidth ± 5 nm); r 5: Near-infrared reflectance with a center wavelength of 840 nm (bandwidth ±15 nm).

[0044] These reflectance values, after radiometric calibration and atmospheric correction, serve as the basic input features of the model and together constitute the spectral information basis for water quality parameter inversion.

[0045] Step 4: SA-MDN Model Building This invention addresses the complex distribution characteristics and uncertainty quantification issues of urban water quality by proposing an integrated Self-Attention Enhanced Mixture Density Network (SA-MDN) architecture. The model combines the feature engineering capabilities of machine learning, the nonlinear representation capabilities of deep learning, and the uncertainty quantification advantages of probabilistic modeling, achieving end-to-end probabilistic prediction.

[0046] Hybrid density network (MDN) is a deep learning model that integrates neural networks and probabilistic modeling. It is primarily used to address the limitations of traditional regression models in handling multimodal output distributions. Water quality is highly susceptible to the combined effects of mixed pollution sources (such as the combined effects of sewage discharge and agricultural runoff), periodic hydrodynamic processes (such as concentration changes caused by tidal fluctuations), and the spatiotemporal heterogeneity of biogeochemical reactions (such as the patchy distribution of algal blooms), resulting in bimodal or even multimodal distributions. MDN can output a complete probability distribution, thus better modeling complex, multimodal data distributions. MDN assumes a target variable... y A Gaussian Mixture Model (GMM) is a weighted combination of multiple Gaussian distributions. The formula for calculating the conditional probability distribution is as follows:

[0047] In the formula, K This indicates the number of Gaussian distributions. π k ( x ) represents the mixed weights, the first k The weights of the Gaussian distribution represent the influence of the distribution on the current input. x The importance of. It is the first k The probability density function of a Gaussian distribution. m k ( x ) represents the mean of this mode. s k ( x The expression ) represents the uncertainty of the mode, as shown in the following formula.

[0048]

[0049] In the above formula, W μ This is the weight matrix of the mean prediction layer. h The feature vector output by the backbone network, b μ Bias term of the mean prediction layer. W σ This is the weight matrix for the standard deviation prediction layer. softplus It is an activation function used to ensure that the standard deviation is positive. b σ This is the bias term for the standard deviation prediction layer.

[0050] While Hybrid Density Networks (MDNs) offer an innovative solution for water quality parameter inversion through probabilistic output, they still face significant challenges in practical urban water environment monitoring applications: 1) Limited by the finite number of spectral bands in multispectral imagery, traditional MDNs lack sufficient feature representation capabilities, making it difficult to fully extract hidden feature information; 2) During training, the multimodal nature of the likelihood function easily leads to gradient instability and mode collapse. These limitations severely restrict the application of the model in complex urban water environments. Therefore, this paper introduces multimodal input through ensemble learning, a hierarchical design of input network + backbone network, self-attention enhanced feature extraction, and a regularized hybrid density loss function into the original MDN, combined with a dynamic early stopping mechanism to prevent data overfitting, ultimately establishing the SA-MDN model.

[0051] SA-MDN significantly improves the feature representation capability and multi-peak modeling accuracy of water quality inversion through a hierarchical design of input network + backbone network. The input network uses high-dimensional mapping and strong regularization to transform the input data into high-dimensional features while suppressing noise interference. The backbone network combines a self-attention mechanism (capturing global dependencies between bands) and a bottleneck structure (compressing the feature dimension to hidden_dim / / 2) to force the model to focus on key discriminative features.

[0052] The original MDN directly fits the mixed distribution parameters using a fully connected network, which makes it difficult to capture the long-range dependencies between band features. Therefore, a multi-head self-attention mechanism is introduced to compute multiple sets of parameters in parallel. Q , K , V Projection enables the model to simultaneously capture the coordinated changes of different band combinations, as shown in equation (4): (4) In the formula, Q For query matrix ,K Key matrix, V Value matrix, X Represents the input feature matrix. W Q Indicates query ( Q The projection weight matrix of ) W K Indicate key ( K The projection weight matrix of ) W V Represents value ( V The projection weight matrix is ​​given. Based on this, residual connectivity and layer normalization are used to further improve the accuracy and stability of water quality parameter inversion, alleviate the gradient vanishing problem, and enhance dynamic adaptability. The calculation is shown in the following formula: (5) In the formula, hin Indicates input features, MultiHead(h in ) For multi-head attention output, LayerNorm Representative level normalization, h mid These are intermediate features after the first residual, representing the feedforward network.

[0053] The regularized hybrid density loss function organically combines negative log-likelihood loss, entropy regularization, and variance constraint. Its core advantage lies in its probabilistic output and dynamic regularization mechanism, which ensures both prediction accuracy and enhanced model robustness. This function prevents mode collapse through entropy regularization, ensuring a reasonable allocation of contributions from different factors. Simultaneously, it uses variance constraints to balance prediction uncertainty, effectively suppressing overfitting and gradient anomalies. Ultimately, it achieves a more accurate model of water quality parameter distribution, as shown in the following equation: (6) In the formula, α Represents the coefficient of the entropy regularization term. β The variance constraint coefficients were determined. Finally, the SA-MDN model was established by combining the dynamic early stopping mechanism.

[0054] Step 5: Accuracy Result Verification In the inversion study of ammonia nitrogen (NH3-N), a non-optically active water quality parameter in rivers, based on UAV multispectral remote sensing, the concentration information of ammonia nitrogen itself lacks significant direct spectral absorption characteristics. Therefore, it needs to be inferred through modeling the indirect correlation with optically active components (such as suspended solids and colored dissolved organic matter). Thus, the scientific evaluation of the inversion model's performance is crucial. To comprehensively and objectively measure the model's predictive ability and error characteristics, this invention employs three classic and complementary regression evaluation indicators: the coefficient of determination (R²), the root mean square error (RMSE), and the mean square error (MSE).

[0055] R² represents the proportion of the measured ammonia nitrogen concentration variability explained by the model, with a value between 0 and 1. The closer the value is to 1, the higher the goodness of fit of the model. The calculation formula is as follows:

[0056] RMSE, expressed in the same unit (mg / L) as ammonia nitrogen concentration, reflects the average deviation between predicted and measured values. It is more sensitive to larger errors and can intuitively reflect the absolute accuracy of the inversion results. The calculation formula is as follows:

[0057] MSE, as the squared form of RMSE, is often used for loss function optimization during model training. It can also reveal the overall discreteness of the error. The calculation formula is as follows:

[0058] In the above formula, y i For the first i The measured value of each sample (e.g., ammonia nitrogen concentration, unit mg / L). i For the first i The model prediction value for each sample. n The total number of samples, This is the average value of the measured values.

[0059] To systematically verify the effectiveness and superiority of the proposed Self-Attention Hybrid Density Network (SA-MDN) in the inversion of ammonia nitrogen concentration in river channels using UAV multispectral remote sensing, this invention selects three representative classical machine learning regression models as benchmark methods for comparative experiments: Support Vector Regression (SVR), K-Nearest Neighbors Regression (KNN), and Random Forest (RF). These models represent the kernel method based on structural risk minimization (SVR), the instance-based nonparametric method (KNN), and the decision tree ensemble strategy (RF) in ensemble learning, respectively, all of which have wide applications in the field of remote sensing water quality inversion.

[0060] All comparison models use the same input features, the same training / test sample partitioning (based on spatial hierarchical sampling to avoid data leakage), a unified preprocessing process, and hyperparameter optimization strategies as SA-MDN. Under this fair comparison framework, the inversion performance of each model on the test set is quantitatively evaluated using three metrics: coefficient of determination (R²), root mean square error (RMSE), and mean square error (MSE), as shown in Table 1.

[0061] Table 1

[0062] The model accuracy evaluation results show that the proposed SA-MDN performs best overall in the ammonia nitrogen retrieval task. Its coefficient of determination (R² = 0.87) is significantly higher than that of SVM (0.80), KNN (0.64), and RF (0.81). Meanwhile, its root mean square error (RMSE = 0.30 mg / L) and mean square error (MSE = 0.09 (mg / L)²) are the lowest, indicating a higher degree of agreement and smaller systematic bias between its predicted and measured values. KNN lags significantly behind due to its sensitivity to local noise and lack of global modeling capabilities. While SVM and RF possess strong nonlinear fitting capabilities, they still have limitations in handling the complex mapping relationship between spectral features and non-optically active water quality parameters. In contrast, SA-MDN effectively captures the dynamic dependencies between multiple bands through a self-attention mechanism and combines a hybrid density network to model prediction uncertainties, thereby improving generalization performance while maintaining high explanatory power and verifying its technical advantages in remote sensing inversion of ammonia nitrogen in urban water bodies.

[0063] Step 6: Analysis of Inversion Results Figure 2 The image shows the spatial distribution of ammonia nitrogen concentration generated by UAV multispectral remote sensing. Overall, the ammonia nitrogen concentration in the river exhibits clear spatial differentiation. Near the intersection of urban residential areas and roads, a significant high-value area (brighter area) exists, indicating that this area may be affected by point source pollution such as domestic sewage discharge or pipeline leakage. Pollutants enter the water body through surface runoff or underground seepage, forming local enrichment. This high-value area spreads downstream along the river, showing a certain migration trend, reflecting the role of hydrodynamic conditions in pollutant transport. A significant increase in concentration was also observed at the junctions where tributaries flow into the main canal, indicating that the tributaries may carry high concentrations of ammonia nitrogen pollutants, becoming one of the main input pathways. Most areas of the main river channel show lower concentrations (darker areas), demonstrating strong dilution and self-purification capabilities. In addition, sporadic high-value points were also observed in water bodies around some green spaces and parks, suggesting possible non-point source pollution or pollutant input from localized rainwater runoff. These results are highly consistent with the spatial distribution of ground sampling data, verifying the reliability of the inversion model. By expressing ammonia nitrogen concentration in a continuous planar form, this method not only breaks through the spatial coverage limitations of traditional discrete sampling, but also intuitively reveals the spatial pattern and propagation path of pollution in urban river networks, providing important scientific basis for identifying pollution sources, assessing water environment risks, and formulating zoned governance strategies.

[0064] This invention has the following significant advantages: 1. High-frequency monitoring and real-time response capabilities: Compared with traditional manual sampling and laboratory analysis methods, this invention achieves efficient monitoring of ammonia nitrogen concentration in complex water systems through remote sensing technology, enabling real-time capture of dynamic changes in ammonia nitrogen concentration in water bodies at a higher frequency. This allows the invention to respond to pollution events more promptly, supporting rapid source tracing and emergency response for water quality.

[0065] 2. Enhancing Inversion Accuracy and Quantifying Prediction Uncertainty: Existing remote sensing inversion methods (such as SVM and RF) generally suffer from the inability to quantify prediction uncertainty and the neglect of complex nonlinear interactions between bands. In contrast, the Self-Attention Enhanced Hybrid Density Network (ESA-MDN) employed in this invention can effectively model the complex dependencies between different bands through a self-attention mechanism and provide multi-source uncertainty predictions in conjunction with an ensemble strategy. This not only improves the accuracy of ammonia nitrogen inversion but also provides users with reliable confidence intervals, significantly enhancing the model's robustness and generalization ability in complex urban water bodies.

[0066] 3. It overcomes the limitations of traditional remote sensing inversion methods: Traditional remote sensing water quality inversion methods, such as support vector machine (SVM) and random forest (RF), are prone to losing key features when there is a high amount of information in low-correlation bands. However, this invention enhances the model's ability to capture different band combinations by introducing a self-attention mechanism, and can better handle complex spectral dependencies in low-correlation bands.

[0067] 4. Technological Innovation and Advancement: The ESA-MDN model adopted in this invention not only integrates self-attention mechanism and ensemble learning, but also introduces a regularized hybrid density loss function, which effectively avoids the gradient instability and mode collapse problems common in model training, thus greatly improving the stability and adaptability of the technology in complex environments.

[0068] Example 2 The present invention also provides a river and lake ammonia nitrogen monitoring device, comprising: The first processing module is used to acquire UAV multispectral image data of the sampling points; The second processing module is used to preprocess the multispectral image data to obtain the surface reflectance data of the sampling points; The third processing module is used to input surface reflectance data into the integrated self-attention enhanced hybrid density network to generate a spatial distribution map of ammonia nitrogen concentration at the sampling points. The self-attention enhanced hybrid density network uses a regularized hybrid density loss function that organically combines negative log-likelihood loss, entropy regularization term and variance constraint term.

[0069] As one embodiment of the present invention, the second processing module preprocesses the multispectral image data including: sensor radiometric calibration, geometric correction, image stitching, reflectivity conversion, and characteristic band selection and modeling.

[0070] In one embodiment of the present invention, the second processing module employs an effective band selection method to identify the bands most relevant to water quality parameters, and determines the bands used for modeling as follows: 1=

[0071] 2=

[0072] 3=

[0073] 4=

[0074] 5=

[0075] Among them, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which i =1,2,3,4,5 correspond to the surface reflectance of five specific wavebands: r 1: Reflectivity of the blue light band with a center wavelength of 450 nm; r 2: Reflectivity in the green light band with a center wavelength of 555 nm; r 3: Reflectivity in the red light band with a center wavelength of 660 nm; r 4: Reflectivity of the red-edge band with a center wavelength of 720 nm; r 5: Near-infrared reflectance with a center wavelength of 840 nm.

[0076] Example 3 The present invention also provides a river and lake ammonia nitrogen monitoring system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a river and lake ammonia nitrogen monitoring method when executed by the processor.

[0077] Example 4 The present invention also provides a storage medium storing a computer program, which executes a method for monitoring ammonia nitrogen in rivers and lakes when running.

[0078] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for monitoring ammonia nitrogen in rivers and lakes, characterized in that, include: Acquire UAV multispectral image data of sampling points; Multispectral image data is preprocessed to obtain surface reflectance data of sampling points; Surface reflectance data is input into an integrated self-attention enhanced hybrid density network to generate a spatial distribution map of ammonia nitrogen concentration at the sampling points. The regularized hybrid density loss function used in the self-attention enhanced hybrid density network organically combines negative log-likelihood loss, entropy regularization term and variance constraint term.

2. The method for monitoring ammonia nitrogen in rivers and lakes as described in claim 1, characterized in that, Preprocessing of multispectral image data includes: sensor radiometric calibration, geometric correction, image stitching, reflectivity conversion, and characteristic band selection and modeling.

3. The method for monitoring ammonia nitrogen in rivers and lakes as described in claim 1, characterized in that, Using an effective band selection method, the bands most relevant to water quality parameters were identified, and the following bands were determined for modeling: , , , , , Among them, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which Surface reflectance corresponding to five specific wavebands: Reflectivity of blue light at a center wavelength of 450 nm; Reflectivity of green light with a center wavelength of 555 nm; Reflectivity of the red light band with a center wavelength of 660 nm; Reflectivity in the red-edge band with a center wavelength of 720 nm; Reflectivity in the near-infrared band with a center wavelength of 840 nm.

4. A monitoring device for ammonia nitrogen in rivers and lakes, characterized in that, include: The first processing module is used to acquire UAV multispectral image data of the sampling points; The second processing module is used to preprocess the multispectral image data to obtain the surface reflectance data of the sampling points; The third processing module is used to input surface reflectance data into the integrated self-attention enhanced hybrid density network to generate a spatial distribution map of ammonia nitrogen concentration at the sampling points. The self-attention enhanced hybrid density network uses a regularized hybrid density loss function that organically combines negative log-likelihood loss, entropy regularization term and variance constraint term.

5. The ammonia nitrogen monitoring device for rivers and lakes as described in claim 4, characterized in that, The second processing module performs preprocessing on the multispectral image data, including sensor radiometric calibration, geometric correction, image stitching, reflectivity conversion, and characteristic band selection and modeling.

6. The ammonia nitrogen monitoring device for rivers and lakes as described in claim 5, characterized in that, The second processing module employs an effective band selection method to identify the bands most relevant to water quality parameters, determining the following bands for modeling: , , , , , Among them, the input variable Band i Represents the first [unit / item] used for machine learning training. i Spectral features, among which Surface reflectance corresponding to five specific wavebands: Reflectivity of blue light at a center wavelength of 450 nm; Reflectivity of green light with a center wavelength of 555 nm; Reflectivity of the red light band with a center wavelength of 660 nm; Reflectivity in the red-edge band with a center wavelength of 720 nm; Reflectivity in the near-infrared band with a center wavelength of 840 nm.

7. A river and lake ammonia nitrogen monitoring system, characterized in that, include: The system includes a memory and a processor, wherein the memory stores a computer program that is executed by the processor, and the computer program, when executed by the processor, performs the method for monitoring ammonia nitrogen in rivers and lakes as described in any one of claims 1-3.

8. A storage medium, characterized in that, The storage medium stores a computer program, which executes the method for monitoring ammonia nitrogen in rivers and lakes as described in any one of claims 1-3 when the computer program is running.

Citation Information

Patent Citations

  • Method and device for identifying ammonia nitrogen, storage medium and apparatus

    CN109269992A

  • Lake permanganate index inversion method based on mixed density network

    CN120164091A