Spatial-temporal graph neural network water quality prediction method based on DEM mapping

By combining DEM mapping and STGCN model, a graph structure that can truly reflect the hydrological connections between monitoring stations was constructed, which solves the shortcomings of existing water quality prediction methods in capturing spatial relationships and improves the accuracy and applicability of water quality prediction.

CN119917796BActive Publication Date: 2025-11-25SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411900117.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-11-25
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

Existing water quality prediction methods are insufficient in capturing the true spatial relationships between water quality monitoring stations, resulting in poor prediction results. In particular, the application scope of physical simulation models is limited, while data-driven models ignore the spatial characteristics and spatiotemporal correlations of water quality changes.

Method used

By extracting the river network topology using DEM data, a graph structure reflecting the hydrological connections between monitoring stations is constructed. Combined with the STGCN model, spatiotemporal features are captured, and a spatiotemporal graph neural network water quality prediction method based on DEM mapping is built.

Benefits of technology

It improves the accuracy of water quality prediction and the applicability of the model, enhances the sensitivity to spatial characteristics, and reduces the reliance on professionals to adjust parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917796B_ABST
    Figure CN119917796B_ABST
Patent Text Reader

Abstract

The application discloses a kind of space-time graph neural network water quality prediction methods based on DEM mapping, comprising: obtaining the DEM data of target area and processing, extract the river topological structure in target area, and then build the graph structure reflecting the spatial relationship of water quality monitoring site;Obtain water quality data and pretreatment, eliminate the influence of missing value and abnormal value;Water quality prediction model is constructed based on STGCN model, and STGCN model includes multiple spatiotemporal convolution blocks, each spatiotemporal convolution block includes time gate convolution layer, spatial graph convolution layer and time gate convolution layer arranged in sequence;Based on the water quality prediction model constructed to detect the water quality to be detected.The application captures the spatial dependence relationship between water quality monitoring sites, improves the accuracy of water quality prediction. By using DEM data to extract river network topological structure, a graph structure that can truly reflect the hydrological connection between monitoring sites is constructed, and the accuracy of water quality prediction is effectively improved by effectively capturing the spatiotemporal characteristics of the STGCN model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of water quality prediction, specifically relating to a spatiotemporal graph neural network-based water quality prediction method based on DEM mapping. Background Technology

[0002] In the fields of environmental protection and water resource management, water quality forecasting plays an indispensable role. It not only helps in the timely adjustment of protection strategies but also supports the shift from passive treatment to proactive prevention, thereby reducing treatment costs and ensuring water resource security. Existing water quality forecasting methods are mainly divided into two categories: physical simulation models and data-driven models.

[0003] Physical simulation models, such as SWAT (Soil and Water Assessment Tool) and MIKE11, rely on detailed input data and parameter adjustments by professionals for specific aquatic environments. While they can provide detailed predictions, their application is limited and they struggle to adapt to changes in different aquatic environments. On the other hand, data-driven models, especially those based on neural networks such as Long Short-Term Memory (LSTM) networks and Gated Recurrent Units (GRUs), excel at capturing nonlinear patterns in water quality data and processing time-series information. However, they typically focus on historical data from a single monitoring point, neglecting the potential spatial characteristics and spatiotemporal correlations in water quality changes, which limits the accuracy of predictions.

[0004] Given that water quality changes are influenced not only by the trends in historical data from various monitoring stations but also by the spatial connectivity of rivers, a method is needed to reveal the spatial connections between monitoring stations within a watershed to improve prediction accuracy. In this context, Graph Neural Networks (GNNs), as a technique capable of processing non-Euclidean spatial data, are particularly important due to their ability to directly model the complex connections between monitoring stations. By utilizing the spatial and temporal information in graph-structured data, GNNs hold the promise of achieving more accurate water quality predictions.

[0005] Currently, there are two main methods for constructing graph structures:

[0006] (1) Mapping based on data correlation: This method defines the graph structure by calculating the correlation coefficient of water quality parameters between different water quality monitoring stations. When the correlation between two stations exceeds a certain threshold, they are considered to be connected. Although this method can reflect the statistical characteristics of water quality data and capture the potential connections between stations, it may not fully consider the actual hydrological connections and environmental factors.

[0007] (2) Mapping based on geographical distance: This method determines whether to establish a connection based on the straight-line distance between monitoring stations. In cases where detailed hydrological data is lacking, this method provides an effective means of map construction, but it may also fail to accurately reflect the actual hydrological path and the influence of factors such as topography on the direction of water flow.

[0008] In summary, current graph structure construction methods are insufficient in capturing the true spatial relationships between water quality monitoring stations, which may lead to poor model prediction performance. To improve this, it is necessary to develop a new graph structure construction method that can more accurately reflect the hydrological connections between monitoring stations, thereby enhancing the model's sensitivity to spatial features and improving prediction accuracy. This new method will bring higher reliability to water quality prediction, thus better serving the needs of environmental protection and water resource management. Summary of the Invention

[0009] The main objective of this invention is to overcome the shortcomings and deficiencies of the existing technology and provide a spatiotemporal graph neural network water quality prediction method based on DEM mapping. By using DEM data to extract the river network topology, a graph structure that can truly reflect the hydrological connections between monitoring stations is constructed. Combined with the STGCN model to effectively capture spatiotemporal features, the accuracy of water quality prediction is effectively improved.

[0010] To achieve the above objectives, the present invention adopts the following technical solution:

[0011] In a first aspect, the present invention provides a spatiotemporal graph neural network-based water quality prediction method based on DEM mapping, comprising the following steps:

[0012] DEM data of the target area is acquired and processed to extract the river topology within the target area, and then a graph structure reflecting the spatial relationship of water quality monitoring stations is constructed.

[0013] Acquire water quality data and preprocess it to eliminate the impact of missing and outlier values;

[0014] A water quality prediction model is constructed based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a temporally gated convolutional layer, a spatial graph convolutional layer, and a temporally gated convolutional layer arranged sequentially.

[0015] The water quality to be tested is detected based on the established water quality prediction model.

[0016] As a preferred technical solution, the step of acquiring and processing DEM data of the target area to extract the river topology within the target area, and then constructing a graph structure reflecting the spatial relationships of water quality monitoring stations, specifically involves:

[0017] High-resolution DEM data of the target area is acquired, and depression filling is used to eliminate non-natural closed depressions in the DEM data. Hydrological analysis tools are used to analyze the flow direction and runoff of the preprocessed DEM data to generate runoff raster data. Based on the runoff raster data and the preset catchment area threshold, preliminary river raster data is generated.

[0018] Convert river raster data into vector line features to generate vector data for the river network;

[0019] Based on the processed river network and monitoring station data, a graph structure reflecting the hydrological relationships between the monitoring stations is constructed. The nodes in the graph structure represent water quality monitoring stations, and the edges represent the river connections between the stations.

[0020] As a preferred technical solution, the hydrological analysis tools used to analyze the flow direction and runoff of the preprocessed DEM data are as follows:

[0021] The D8 algorithm is used to calculate the water flow direction of each cell to generate flow direction raster data, and then the catchment area of ​​each cell is calculated to generate catchment volume raster data.

[0022] To extract the main river flow lines, a reasonable catchment area threshold was set based on the runoff raster data to filter out insignificant runoff paths and retain only the main river paths.

[0023] The conditional tools are used to binarize the runoff raster to generate preliminary river raster data. The river linking tools are then used to mark the connections between river segments, resulting in a complete topological structure of the river network.

[0024] As a preferred technical solution, the step of converting river raster data into vector line features to generate vector data of the river network specifically involves:

[0025] Topology tools are used to perform topology checks and corrections on vector river networks, eliminating hanging nodes, broken segments, and duplicate segments to ensure the accuracy of the river network's topological relationships.

[0026] In order to identify the main stream and tributaries of a river, this embodiment uses the Strahler classification method to classify the river.

[0027] Collect the geographic coordinates and related attribute information of water quality monitoring stations in the target area, import the monitoring stations into ArcGIS, and spatially overlay them with river network vector data;

[0028] Use the capture tool to capture the monitoring station onto the nearest river line, set the capture tolerance, and ensure that the monitoring station is accurately located on the corresponding river line.

[0029] As a preferred technical solution, the step of constructing a graph structure reflecting the hydrological relationships of the monitoring stations based on the processed river network and monitoring station data specifically involves:

[0030] The network analysis module was used to calculate the shortest path lengths along the river between monitoring stations;

[0031] The edge weight is calculated using the following exponential decay function, meaning the edge weight decreases exponentially as the flow length increases, as shown in the formula:

[0032]

[0033] In the formula: (A) ij ) is the weight of edge (i,j), d(i,j) is the original distance of edge (i,j), max(d) is the maximum value of the distances of all edges, and λ is the decay rate parameter.

[0034] As a preferred technical solution, the acquisition and preprocessing of water quality data to eliminate the influence of missing and outlier values ​​specifically includes:

[0035] Lagrange interpolation was used to handle missing values;

[0036] The data is smoothed using an exponentially weighted moving average method;

[0037] All data are normalized to the [0,1] interval, thus ensuring that different features are processed and analyzed on the same scale.

[0038] As a preferred technical solution, in the step of constructing a water quality prediction model based on the STGCN model...

[0039] Define the input at a certain moment for each monitoring point as:

[0040]

[0041] In the formula: N represents the number of monitoring stations, and C is the dimension of the input node features;

[0042] The entire watershed is viewed as a graph, with water quality monitoring stations as nodes and river connections as edges connecting nodes. A dynamic graph expands the original graph structure by adding a time dimension. The graph structure remains unchanged at each time point, and the impact of time changes on water quality is better analyzed by varying the attributes of each vertex. Based on this, a graph G reflecting the relationships between stations is constructed.

[0043] G t =(V t (E, A)

[0044] In the formula, V is the node vector of each station, E is the edge vector of the connecting edge of each station, and A is the adjacency matrix of the graph, where the adjacency matrix formula is:

[0045]

[0046] In summary, the problem of predicting all water quality indicators is defined as follows:

[0047]

[0048] In the formula: H represents the predicted output of the model, H represents the length of the input time window of the model, and f represents the water quality prediction model.

[0049] As a preferred technical solution, the formula for each spatiotemporal convolutional block is:

[0050]

[0051] In the formula: v l+1 and v l These are the output and input of the l-th layer, respectively. and These are the temporal convolution kernels used within the block for the lower and upper layers, respectively.

[0052] The formula for the time-gated convolutional layer is:

[0053]

[0054] In the formula: Γ *T The temporal convolution operation is represented by Y, which is the input feature matrix. P and Q are matrices representing the result of the convolution kernel Γ on the input Y. They represent the two input parts of the gated unit GLU, σ(Q) is the result of Q after processing by the sigmoid function, and ⊙ represents the Hadamard product.

[0055] The formula for the spatial graph convolutional layer is:

[0056]

[0057] In the formula: Θ *G This indicates applying a convolution kernel to graph data, where x is the input feature matrix, θ is the convolution kernel parameter, and I... n The identity matrix has the same dimensions as the number of nodes in the graph, D is the degree matrix, and W is the weighted adjacency matrix of the graph.

[0058] Secondly, the present invention provides a spatiotemporal graph neural network water quality prediction system based on DEM mapping, which is applied to the aforementioned spatiotemporal graph neural network water quality prediction method based on DEM mapping, including a DEM data processing module, a water quality data preprocessing module, a water quality prediction model construction module, and a water quality prediction module.

[0059] The DEM data processing module is used to acquire and process DEM data of the target area, extract the river topology within the target area, and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations.

[0060] The water quality data preprocessing module is used to acquire water quality data and preprocess it to eliminate the influence of missing values ​​and outliers.

[0061] The water quality prediction model is used to construct a water quality prediction model based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a time-gated convolutional layer, a spatial graph convolutional layer, and a time-gated convolutional layer arranged sequentially.

[0062] The water quality prediction module detects the water quality to be tested based on the constructed water quality prediction model.

[0063] Thirdly, the present invention provides an electronic device, the electronic device comprising:

[0064] At least one processor; and,

[0065] A memory communicatively connected to the at least one processor; wherein,

[0066] The memory stores computer program instructions that can be executed by the at least one processor, which are executed by the at least one processor to enable the at least one processor to execute the spatiotemporal neural network water quality prediction method based on DEM mapping.

[0067] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0068] Improving prediction accuracy: This invention utilizes the river network topology extracted from DEM data to construct a graph structure that truly reflects the hydrological connections between monitoring stations, thereby improving the model's ability to capture spatial features and enhancing the accuracy of water quality prediction.

[0069] Making full use of spatial and temporal features: The STGCN model of this invention effectively combines spatial graph convolution and temporal convolution, and can simultaneously capture the spatial dependence and temporal dynamics of water quality data.

[0070] Enhancing the model's generalization ability: This invention uses a graph structure construction method based on physical geographic information, which makes the model more applicable to different aquatic environments and reduces the reliance on professionals to adjust parameters. Attached Figure Description

[0071] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0072] Figure 1 This is a flowchart of the spatiotemporal graph neural network water quality prediction method based on DEM mapping, according to an embodiment of the present invention.

[0073] Figure 2 This is a schematic diagram illustrating the extraction of river network information according to an embodiment of the present invention;

[0074] Figure 3 This is a schematic diagram of the spatiotemporal graph convolutional block structure according to an embodiment of the present invention;

[0075] Figure 4 This is a block diagram of the spatiotemporal graph neural network water quality prediction system based on DEM mapping, according to an embodiment of the present invention.

[0076] Figure 5 This is a structural diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0077] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0078] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.

[0079] Definitions of abbreviations and key terms:

[0080] 1. Abbreviations and their full names:

[0081] DEM (Digital Elevation Model): A model that represents the elevation of the Earth's surface in digital form, usually in the form of a regular grid, where each cell represents the elevation of the Earth's surface.

[0082] GNN (Graph Neural Network): A neural network model capable of directly processing graph-structured data, suitable for analyzing non-Euclidean space data with complex relationships between nodes.

[0083] STGCN (Spatio-Temporal Graph Convolutional Network): A deep learning model that combines temporal and spatial graph convolutions to process graph-structured data with spatio-temporal dependencies, capturing the spatial and temporal features of the data.

[0084] CNN (Convolutional Neural Network): Primarily used for processing Euclidean spatial data with a grid structure, such as images and videos.

[0085] LSTM (Long Short-Term Memory): A type of recurrent neural network capable of learning long-term dependencies, particularly adept at processing sequential data.

[0086] GRU (Gated Recurrent Unit): A recurrent neural network similar to LSTM, but with a simpler structure, capable of capturing temporal dependencies in sequential data.

[0087] GIS (Geographic Information System): A computer system used to collect, store, analyze, and display geospatial data.

[0088] MSE (Mean Squared Error): A loss function used to measure the difference between model predictions and actual values; a smaller value indicates better model performance.

[0089] MAE (Mean Absolute Error): A metric that assesses the average absolute difference between predicted and actual values.

[0090] RMSE (Root Mean Squared Error): The square root of the mean square error, often used to measure the accuracy of a predictive model.

[0091] MAPE (Mean Absolute Percentage Error): Represents the percentage of the average relative error between the predicted and actual values.

[0092] R 2(Coefficient of Determination): A metric used to evaluate the goodness of fit of a model. Its value ranges from 0 to 1, with values ​​closer to 1 indicating a better model fit.

[0093] The D8 algorithm (Deterministic 8-node algorithm) is used to calculate the direction of water flow in each cell of a raster DEM, assuming that the water flow can only flow to one of its eight neighboring cells.

[0094] Adam optimization algorithm (Adaptive Moment Estimation): An adaptive moment estimation optimization algorithm. A commonly used gradient descent optimization algorithm that combines the advantages of momentum and adaptive learning rate, suitable for training deep neural networks.

[0095] ReLU (Rectified Linear Unit): A commonly used activation function that outputs the maximum of the input value and zero. It introduces non-linearity to address the vanishing gradient problem in neural networks.

[0096] 2. Definitions of key terms:

[0097] River network topology:

[0098] The structure describing the connections between river segments in a river network reflects the spatial layout and flow paths of the rivers. River network topology is used to simulate the transmission process of water flow within the river network and is the basis for hydrological models and environmental predictions.

[0099] Flow to raster data:

[0100] This refers to the raster data representing the direction of water flow in each cell of a raster DEM. The flow direction determines which neighboring cell the water flows from the current cell to. Commonly used flow direction encoding methods include the D8 algorithm.

[0101] Sink flow raster data:

[0102] Raster data representing the catchment area or cumulative water flow of each grid cell. The catchment area is used to identify the location and size of a river; a larger catchment area indicates a greater accumulation of upstream water at that location.

[0103] Strahler classification method:

[0104] A method for classifying river networks. The classification is based on the confluence of rivers; when two rivers of the same class merge, the classification of their downstream section increases by one. Higher classifications indicate larger river scale, and this method is commonly used in river network analysis and hydrological research.

[0105] Exponential decay function:

[0106] A mathematical function that represents the exponential decrease of a quantity as distance, time, or other variables increase. It is commonly used to simulate the decay process of physical quantities, such as light intensity and signal attenuation.

[0107] Weighted adjacency matrix:

[0108] In graph structures, a weighted adjacency matrix is ​​a matrix used to represent the connections between nodes. The elements of the matrix represent the weights of the edges between nodes, reflecting the strength or distance of the connections. Weighted adjacency matrices are fundamental to graph convolution operations.

[0109] Gated Convolutional Unit:

[0110] A unit in a neural network that combines convolutional operations and gating mechanisms. By introducing gating mechanisms, the flow of information is controlled, the temporal or spatial dependencies of data are captured, and the expressive power of the model is improved.

[0111] Activation function:

[0112] Nonlinear transformation functions in neural networks are used to introduce nonlinear characteristics and enhance the expressive power of the model. Commonly used activation functions include ReLU, Sigmoid, and Tanh.

[0113] Hadamard product:

[0114] The result of multiplying corresponding elements of two matrices or vectors. Also known as element-wise product or dot product, it is used in neural networks to implement gating and attention mechanisms, etc.

[0115] Network Analysis:

[0116] In Geographic Information Systems (GIS), methods are used to analyze network structures (such as roads and rivers). These include shortest path calculation, flow allocation, and accessibility analysis, and are widely applied in fields such as transportation planning and water resource management.

[0117] Capture tools:

[0118] In GIS software, snapping is a tool used to accurately locate spatial features such as points, lines, and polygons onto other spatial features. By setting snapping tolerances, the correct topological relationships of the data are ensured, avoiding errors in spatial analysis.

[0119] Lagrange interpolation:

[0120] A numerical analysis method that constructs a polynomial interpolation function using known data points to estimate the values ​​of unknown data points. It is commonly used for handling missing data and data smoothing.

[0121] Exponentially Weighted Moving Average (EWMA):

[0122] A smoothing method for time series data. It assigns exponentially decreasing weights to historical data points and higher weights to newer data points, effectively reducing random noise and capturing data trends.

[0123] like Figure 1 As shown, this embodiment provides a spatiotemporal graph neural network-based water quality prediction method based on DEM mapping, including the following steps:

[0124] S1. River network extraction and graph structure construction;

[0125] Furthermore, this embodiment proposes a method for river network extraction and graph structure construction based on a Digital Elevation Model (DEM). It primarily utilizes Geographic Information System (GIS) technology to process DEM data, extracting the river channel topology within the study area (i.e., the target area), and then constructing a graph structure reflecting the spatial relationships of water quality monitoring stations. A DEM is a model that digitally represents the elevation of the Earth's surface. It expresses the distribution of surface elevation through regular grids or irregular triangular meshes, with each cell representing the altitude of a specific location. It serves as fundamental data for topographic analysis and hydrological simulation.

[0126] Furthermore, the specific steps for constructing a graph structure are as follows:

[0127] S11. Obtain high-resolution DEM data of the study area to ensure that the accuracy of the terrain data meets the requirements for river network extraction. To address the potential noise and missing data issues in the original DEM data, depression filling is used to eliminate non-naturally closed depressions in the terrain data, avoiding the generation of incorrect catchment points in flow direction calculations.

[0128] Furthermore, based on the preprocessed DEM data, flow direction and runoff analysis were performed using ArcGIS's hydrological analysis tools. The D8 algorithm was used to calculate the flow direction of each cell, generating flow direction raster data. Then, the catchment area of ​​each cell was calculated to generate runoff raster data. To extract the main river channels, a reasonable catchment area threshold was set based on the runoff raster data to filter out insignificant runoff paths, retaining only the main river paths. Then, the conditional tools were used to binarize the runoff raster, generating preliminary river channel raster data. The river linking tool was used to mark the connections between river segments, ensuring the integrity of the river network's topology.

[0129] S12. Convert the river raster data into vector line features to generate vector data for the river network, such as... Figure 2As shown in parts (a) and (b) of the diagram. Topology tools were used to perform topological checks and corrections on the vector river network, eliminating dangling nodes, broken segments, and duplicate segments to ensure accurate topological relationships. To identify the main streams and tributaries of rivers, the Strahler classification method was used to classify the rivers. Subsequently, the geographic coordinates and relevant attribute information of water quality monitoring stations within the study area were collected, imported into ArcGIS, and spatially overlaid with the river network vector data. A snapping tool was used to snap the monitoring stations to the nearest river channel line, with a snapping tolerance set to 30 meters to ensure that the monitoring stations were accurately located on their corresponding river channels.

[0130] S13. Based on the processed river network and monitoring station data, construct a graph structure reflecting the hydrological relationships between the monitoring stations. Nodes in the graph represent water quality monitoring stations, and edges represent river connections between stations. To quantify the hydrological impact between monitoring stations, the weight of each edge is calculated primarily considering the actual river course length. Using the network analysis module, the shortest path length between monitoring stations along the river course is calculated. The edge weight is calculated using the following exponential decay function, meaning the edge weight decreases exponentially with increasing course length. The formula is:

[0131]

[0132] In the formula: (A) ij ) is the weight of edge (i,j), d(i,j) is the original distance of edge (i,j), max(d) is the maximum value of the distances of all edges, and λ is the decay rate parameter.

[0133] The graph structure constructed in this way can more accurately reflect the hydrological relationships between monitoring points, thereby enhancing the model's sensitivity to spatial connections when predicting water quality changes. Furthermore, this method allows the model to focus more on nodes spatially close to the current node, while naturally reducing the influence of more distant nodes.

[0134] S2. Preprocess the acquired water quality data;

[0135] Understandably, the acquired water quality data contained some missing and outlier values. To ensure data integrity and quality, Lagrange interpolation was used to handle missing values. Furthermore, to reduce random fluctuations and noise in the data, an exponentially weighted moving average was used for data smoothing. Simultaneously, since the units and orders of magnitude of the monitoring indicators differ, all data were normalized to eliminate dimensional differences and avoid interference with model training. Each data point was normalized to the [0,1] interval, ensuring that different features were processed and analyzed on the same scale.

[0136] The normalization formula is:

[0137]

[0138] In the formula: x is the water quality indicator monitoring value, x′ is the normalized value, and min(x) and max(x) are the minimum and maximum values ​​of the sample data.

[0139] S3. Construct a water quality prediction model based on the STGCN model;

[0140] Step S3 is as follows:

[0141] Define the input at a certain moment for each monitoring point as:

[0142]

[0143] In the formula: N represents the number of monitoring stations, and C is the dimension of the input node features.

[0144] The entire watershed is viewed as a graph, with water quality monitoring stations as nodes and river-channel connections as edges connecting these nodes. A dynamic graph expands the original graph structure by incorporating a time dimension. The graph structure remains constant at each time point, while the impact of time-related changes on water quality is better analyzed by modifying the attributes of each vertex. Based on this, a graph G reflecting the relationships between the stations is constructed:

[0145] G t =(Vt, E, A) (4)

[0146] In the formula, V is the node vector of each station, E is the edge vector of the connecting edge of each station, and A is the adjacency matrix of the graph, where the adjacency matrix formula is:

[0147]

[0148] In summary, the problem of predicting all water quality indicators is defined as follows:

[0149]

[0150] In the formula: H represents the predicted output of the model, H represents the length of the input time window of the model, and f represents the water quality prediction model.

[0151] Furthermore, the STGCN model includes multiple spatiotemporal convolutional blocks, such as... Figure 3 As shown, each spatiotemporal convolutional block includes a temporally gated convolutional layer, a spatial graph convolutional layer, and a temporally gated convolutional layer arranged in sequence. The model uses this "sandwich"-like structure to effectively mine spatial and temporal features.

[0152] The formula for each spatiotemporal convolutional block is:

[0153]

[0154] In the formula: v l+1 and v l These are the output and input of the l-th layer, respectively. and These are the temporal convolution kernels used within the block for the lower and upper layers, respectively.

[0155] The formula for the time-gated convolutional layer is:

[0156]

[0157] In the formula: Γ *T Let Y be the input feature matrix, P and q be matrices representing the result of the convolution kernel Γ on the input Y, Γ represent the two input parts of the gated unit GLU, σ(Q) is the result of Q after processing by the sigmoid function, and ⊙ represents the Hadamard product.

[0158] The formula for the spatial graph convolutional layer is:

[0159]

[0160] In the formula: Θ *G This indicates applying a convolution kernel to graph data, where x is the input feature matrix, θ is the convolution kernel parameter, and I... n The identity matrix has the same dimensions as the number of nodes in the graph, D is the degree matrix, and W is the weighted adjacency matrix of the graph.

[0161] S4. Based on the constructed water quality prediction model, the water quality to be tested is detected. This embodiment improves the accuracy of water quality prediction by capturing the spatial dependencies between water quality monitoring stations. By extracting the river network topology using DEM data, a graph structure that can truly reflect the hydrological connections between monitoring stations is constructed. Combined with the STGCN model's effective capture of spatiotemporal characteristics, the accuracy of water quality prediction is effectively improved.

[0162] In one embodiment, the technical solution of the present invention is further illustrated using a major river in Guangzhou as an example, selecting nine water quality monitoring stations within the study area. The monitoring indicators include four water quality parameters: dissolved oxygen content, pH value, permanganate content, and total phosphorus content.

[0163] The water quality monitoring data used in this embodiment comes from the National Surface Water Quality Automatic Monitoring System. Data was collected from nine stations in the study area, covering the period from November 3, 2022 to December 25, 2023. Sampling was performed every four hours, resulting in 2510 data sets. To ensure the effectiveness of model training, the dataset was divided into training, validation, and test sets in a 3:1:1 ratio according to time sequence.

[0164] During data preprocessing, the effective values ​​of each water quality indicator were limited with reference to the national surface water environmental quality standards in order to exclude outliers and erroneous values. The specific water quality parameters and their effective value ranges are shown in Table 1.

[0165] Table 1 Water quality parameters and effective value range

[0166]

[0167] During the experimental design phase, the model code was written in Python 3.8 and built using the PyTorch framework. The model's hyperparameters were set as follows: Adam optimization algorithm, initial learning rate of 0.001, and weight decay of 0.0001 to prevent overfitting. To improve convergence speed, a cosine annealing learning rate scheduler was used, with a maximum of 32 iterations and a minimum learning rate of 0.0001. The mean squared error (MSE) loss function was chosen, as it is a key function in regression tasks for quantifying the difference between predicted and true values.

[0168] Based on the prediction problem, the model uses historical water quality data from nine stations over the past 18 time steps (i.e., the past 72 hours) to predict dissolved oxygen values ​​at the next time step (4 hours later). The model was trained for 120 epochs with a batch size of 24 to balance memory efficiency and training stability. To reduce the impact of randomness, the model was trained independently five times, and the average of the five experimental results was used as the final result.

[0169] After training, the model is evaluated on the test set using multiple evaluation metrics to comprehensively assess its predictive performance. Evaluation metrics include Mean Absolute Error (MAE), Root Mean Square Error (RMSE), Mean Absolute Percentage Error (MAPE), and Coefficient of Determination (R²). 2 The smaller the values ​​of MAE, RMSE, and MAPE, the larger the R² value, indicating that the model performs better in the prediction task.

[0170] To verify the effectiveness of the STGCN model built on DEM in water quality prediction, this embodiment compares the model with STGCN models based on data correlation mapping and mapping based on straight-line distance between stations. Furthermore, to further verify the performance of the STGCN model, this embodiment compares it with common prediction models such as the traditional graph neural network model GCN, and traditional machine learning models GRU, LSTM, and MLP. The water quality prediction results of each model are shown in Table 2.

[0171] Table 2 compares the predictive performance of the proposed model with the other comparative models.

[0172]

[0173] Experimental results show that the STGCN model based on DEM mapping proposed in this embodiment outperforms other models on all evaluation metrics, exhibiting the best predictive performance. When compared with traditional GCN, GRU, LSTM, and MLP models using different mapping methods, the STGCN models all show certain advantages, indicating that models based on spatiotemporal graph neural networks have a certain advantage in capturing spatial dependencies.

[0174] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously.

[0175] Based on the same idea as the DEM-based spatiotemporal graph neural network water quality prediction method in the above embodiments, this invention also provides a DEM-based spatiotemporal graph neural network water quality prediction system, which can be used to execute the above-described DEM-based spatiotemporal graph neural network water quality prediction method. For ease of explanation, the schematic diagram of the DEM-based spatiotemporal graph neural network water quality prediction system embodiment only shows the parts related to the embodiments of this invention. Those skilled in the art will understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.

[0176] Please see Figure 4 In another embodiment of this application, a spatiotemporal graph neural network water quality prediction system 100 based on DEM mapping is provided. The system includes a DEM data processing module 101, a water quality data preprocessing module 102, a water quality prediction model construction module 103, and a water quality prediction module 104.

[0177] The DEM data processing module 101 is used to acquire and process DEM data of the target area, extract the river topology within the target area, and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations.

[0178] The water quality data preprocessing module 102 is used to acquire water quality data and preprocess it to eliminate the influence of missing values ​​and outliers.

[0179] The water quality prediction model 103 is used to construct a water quality prediction model based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a time-gated convolutional layer, a spatial graph convolutional layer, and a time-gated convolutional layer arranged sequentially.

[0180] The water quality prediction module 104 detects the water quality to be tested based on the constructed water quality prediction model.

[0181] It should be noted that the spatiotemporal graph neural network water quality prediction system based on DEM mapping of the present invention corresponds one-to-one with the spatiotemporal graph neural network water quality prediction method based on DEM mapping of the present invention. The technical features and beneficial effects described in the embodiments of the spatiotemporal graph neural network water quality prediction method based on DEM mapping are applicable to the embodiments of the spatiotemporal graph neural network water quality prediction based on DEM mapping. For details, please refer to the description in the embodiments of the method of the present invention, which will not be repeated here.

[0182] Furthermore, in the above embodiments of the spatiotemporal neural network water quality prediction system based on DEM mapping, the logical division of each program module is only an example. In actual applications, the above functions can be assigned to different program modules as needed, for example, for the sake of corresponding hardware configuration requirements or software implementation convenience. That is, the internal structure of the spatiotemporal neural network water quality prediction system based on DEM mapping is divided into different program modules to complete all or part of the functions described above.

[0183] Please see Figure 5 In one embodiment, an electronic device is provided for implementing a spatiotemporal graph neural network water quality prediction method based on DEM mapping. The electronic device 200 may include a first processor 201, a first memory 202 and a bus, and may also include a computer program stored in the first memory 202 and executable on the first processor 201, such as a spatiotemporal graph neural network water quality prediction program 203 based on DEM mapping.

[0184] The first memory 202 includes at least one type of readable storage medium, including flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the first memory 202 can be an internal storage unit of the electronic device 200, such as the portable hard drive of the electronic device 200. In other embodiments, the first memory 202 can also be an external storage device of the electronic device 200, such as a plug-in portable hard drive, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 200. Furthermore, the first memory 202 can include both internal storage units and external storage devices of the electronic device 200. The first memory 202 can be used not only to store application software and various types of data installed on the electronic device 200, such as the code of the spatiotemporal neural network water quality prediction program 203 based on DEM mapping, but also to temporarily store data that has been output or will be output.

[0185] In some embodiments, the first processor 201 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The first processor 201 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the first memory 202 and calls data stored in the first memory 202 to perform various functions of the electronic device 200 and process data.

[0186] Figure 5 Only electronic devices with components are shown; it will be understood by those skilled in the art that... Figure 5 The structure shown does not constitute a limitation on the electronic device 200, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.

[0187] The spatiotemporal graph neural network water quality prediction program 203 based on DEM mapping, stored in the first memory 202 of the electronic device 200, is a combination of multiple instructions. When run in the first processor 201, it can achieve the following:

[0188] DEM data of the target area is acquired and processed to extract the river topology within the target area, and then a graph structure reflecting the spatial relationship of water quality monitoring stations is constructed.

[0189] Acquire water quality data and preprocess it to eliminate the impact of missing and outlier values;

[0190] A water quality prediction model is constructed based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a temporally gated convolutional layer, a spatial graph convolutional layer, and a temporally gated convolutional layer arranged sequentially.

[0191] The water quality to be tested is detected based on the established water quality prediction model.

[0192] Furthermore, if the modules / units integrated in the electronic device 200 are implemented as software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).

[0193] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0194] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0195] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A spatiotemporal graph neural network-based water quality prediction method based on DEM mapping, characterized in that, Includes the following steps: High-resolution DEM data of the target area was acquired, and depression filling was used to eliminate non-natural closed depressions in the DEM data. Hydrological analysis tools were used to analyze the flow direction and runoff of the preprocessed DEM data. The D8 algorithm was used to calculate the flow direction of each cell to generate runoff raster data. Based on the runoff raster data and a preset catchment area threshold, preliminary river raster data was generated. In order to extract the main river flow lines, a reasonable catchment area threshold was set according to the runoff raster data to filter out insignificant runoff paths and retain only the main river paths. Conditional tools were used to binarize the runoff raster to generate preliminary river raster data. The connection relationship between river segments was marked using the river linking tool to obtain the complete topological structure of the river network. The river raster data is converted into vector line features to generate vector data of the river network. Specifically, topology tools are used to perform topology checks and corrections on the vector river network to eliminate hanging nodes, broken segments, and duplicate segments, ensuring the accuracy of the river network's topological relationships. In order to identify the main streams and tributaries of the rivers, the Strahler classification method is used to classify the rivers. Collect the geographic coordinates and related attribute information of water quality monitoring stations in the target area, import the monitoring stations into ArcGIS, and spatially overlay them with river network vector data; Use a capture tool to capture the monitoring station onto the nearest river line, set the capture tolerance, and ensure that the monitoring station is accurately located on the corresponding river line. Based on the processed river network and monitoring station data, a graph structure reflecting the hydrological relationships between the monitoring stations is constructed. The nodes in the graph structure represent water quality monitoring stations, and the edges represent the river connections between stations. Acquire water quality data and preprocess it to eliminate the impact of missing and outlier values; A water quality prediction model is constructed based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a temporally gated convolutional layer, a spatial graph convolutional layer, and a temporally gated convolutional layer arranged sequentially. The water quality to be tested is detected based on the established water quality prediction model.

2. The spatiotemporal graph neural network water quality prediction method based on DEM mapping according to claim 1, characterized in that, Based on the processed river network and monitoring station data, a graph structure reflecting the hydrological relationships among the monitoring stations is constructed, specifically as follows: The network analysis module was used to calculate the shortest path lengths along the river between monitoring stations; The edge weight is calculated using the following exponential decay function, meaning the edge weight decreases exponentially as the flow length increases, as shown in the formula: ; In the formula: ( A ij ) is an edge ( i , j The weight of ) d ( i , j ) is an edge ( i , j The original distance, max ( d ) is the maximum distance of all edges. λ It is the decay rate parameter.

3. The spatiotemporal graph neural network water quality prediction method based on DEM mapping according to claim 1, characterized in that, The process of acquiring water quality data and preprocessing it to eliminate the influence of missing and outlier values ​​specifically involves: Lagrange interpolation was used to handle missing values; The data is smoothed using an exponentially weighted moving average method; All data are normalized to the [0,1] interval, thus ensuring that different features are processed and analyzed on the same scale.

4. The spatiotemporal graph neural network water quality prediction method based on DEM mapping according to claim 1, characterized in that, In the steps of constructing a water quality prediction model based on the STGCN model... Define the input at a certain moment for each monitoring point as: ; In the formula: N Indicates the number of monitoring stations. C The dimension of the node features is the input. The entire watershed is viewed as a graph, with water quality monitoring stations as nodes and riverbank connections as edges connecting these nodes. A dynamic graph expands the original graph structure by incorporating a time dimension. The graph structure remains constant at each time point, while the attributes of each vertex are varied to better analyze the impact of time changes on water quality. This allows for the construction of a graph reflecting the relationships between the monitoring stations. G : ; In the formula, V For each station's node vector, E Let the edge vectors of the edges connecting each station be denoted as . A Let be the adjacency matrix of the graph, where the adjacency matrix formula is: ; in,( A ij ) is an edge ( i , j The weight of ); In summary, the problem of predicting all water quality indicators is defined as follows: ; In the formula: This represents the model's predicted output. H Indicates the length of the model input time window. f This represents a water quality prediction model.

5. A spatiotemporal graph neural network water quality prediction system based on DEM mapping, characterized in that, It includes a DEM data processing module, a water quality data preprocessing module, a water quality prediction model building module, and a water quality prediction module; The DEM data processing module is used to acquire high-resolution DEM data of the target area, and to eliminate non-natural closed depressions in the DEM data through depression filling. Hydrological analysis tools are used to analyze the flow direction and runoff of the preprocessed DEM data. The D8 algorithm is used to calculate the flow direction of each pixel, generating runoff raster data. Based on the runoff raster data and a preset catchment area threshold, preliminary river raster data is generated. To extract the main river flow lines, a reasonable catchment area threshold is set according to the runoff raster data to filter out insignificant runoff paths, retaining only the main river paths. Conditional tools are used to binarize the runoff raster, generating preliminary river raster data. River linking tools are used to mark the connection relationships between river segments, obtaining a complete topological structure of the river network. The river raster data is converted into vector line features to generate vector data of the river network. Specifically, topology tools are used to perform topological checks and corrections on the vector river network, eliminating hanging nodes, broken segments, and duplicate segments to ensure accurate topological relationships. To identify the main streams and tributaries of rivers, the Strahler classification method is used to classify the rivers. Collect the geographic coordinates and related attribute information of water quality monitoring stations in the target area, import the monitoring stations into ArcGIS, and spatially overlay them with river network vector data; The monitoring stations are captured using a capture tool to the nearest river line. A capture tolerance is set to ensure that the monitoring stations are accurately located on the corresponding river channels. Based on the processed river network and monitoring station data, a graph structure reflecting the hydrological relationships between the monitoring stations is constructed. The nodes in the graph structure represent water quality monitoring stations, and the edges represent the river connections between the stations. The water quality data preprocessing module is used to acquire water quality data and preprocess it to eliminate the influence of missing values ​​and outliers. The water quality prediction model is used to construct a water quality prediction model based on the STGCN model. The STGCN model includes multiple spatiotemporal convolutional blocks, and each spatiotemporal convolutional block includes a time-gated convolutional layer, a spatial graph convolutional layer, and a time-gated convolutional layer arranged sequentially. The water quality prediction module detects the water quality to be tested based on the constructed water quality prediction model.

6. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the spatiotemporal graph neural network water quality prediction method based on DEM mapping as described in any one of claims 1-4.

Citation Information

Patent Citations

  • STGCN-based flood forecast error real-time correction method and system

    CN115755219A

  • Method and system for traffic prediction based on space-time relation

    US20110161261A1