Space-time diagram neural network water quality prediction method based on DEM composition

Through the graph structure and STGCN model built based on DEM data, the problem of difficulty in accurately capturing the spatial relationship between monitoring sites in the prior art is solved, and higher water quality prediction accuracy and model generalization ability are achieved.

CN119917796AActive Publication Date: 2025-05-02SOUTH CHINA AGRICULTURAL UNIVERSITY

Patent Information

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

AI Technical Summary

Technical Problem

Existing water quality prediction methods are difficult to accurately capture the real spatial relationship between monitoring sites, resulting in poor prediction results.

Method used

The graph structure constructed based on DEM data is adopted to extract the river network topology structure, and a graph structure reflecting the hydrological connection between monitoring sites is constructed, and the spatial and temporal characteristics are captured in combination with the STGCN model.

Benefits of technology

It improves the model's sensitivity to spatial characteristics, improves the accuracy of water quality prediction, and enhances the generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917796A_ABST
    Figure CN119917796A_ABST
Patent Text Reader

Abstract

The invention discloses a time-space diagram neural network water quality prediction method based on DEM composition, and the method comprises the steps: obtaining and processing DEM data of a target region, extracting a river topological structure in the target region, and constructing a graph structure reflecting the spatial relation of water quality monitoring stations; acquiring water quality data, preprocessing the data, and eliminating the influence of missing values and abnormal values; a water quality prediction model is constructed based on an STGCN model, the STGCN model comprises a plurality of space-time convolution blocks, and each space-time convolution block comprises a time gating convolution layer, a space graph convolution layer and a time gating convolution layer which are arranged in sequence; and detecting the water quality to be detected based on the constructed water quality prediction model. According to the method, the accuracy of water quality prediction is improved by capturing the spatial dependency relationship between the water quality monitoring stations. A river network topological structure is extracted by using DEM data, a graph structure capable of truly reflecting hydrological relation between monitoring stations is constructed, and the accuracy of water quality prediction is effectively improved by combining effective capture of the STGCN model on spatio-temporal characteristics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of water quality prediction, and in particular relates to a spatiotemporal graph neural network water quality prediction method based on DEM composition. Background Art

[0002] In the field of environmental protection and water resources management, water quality prediction plays an indispensable role. It not only helps to adjust protection strategies in a timely manner, but also supports the transition from passive governance to active prevention, thereby reducing governance costs and ensuring the safety of water resources. Existing water quality prediction 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 water environments. Although they can provide detailed prediction results, their application scope is limited and they are difficult to adapt to changes in different water environments. On the other hand, data-driven models, especially those based on neural networks, such as long short-term memory networks (LSTM) and gated recurrent units (GRU), are good at capturing nonlinear patterns in water quality data and processing time series information. However, they usually focus on historical data from a single monitoring point and ignore the potential spatial characteristics and spatiotemporal correlations in water quality changes, which limits the accuracy of predictions.

[0004] Given that water quality changes are not only subject to the trend of historical data at each monitoring station, but also affected by the spatial connectivity of the river, a method that can reveal the spatial connection relationship between monitoring stations in the basin is needed to improve prediction accuracy. In this context, graph neural network (GNN), as a technology that can process non-Euclidean spatial data, is particularly important because it can directly model the complex connection relationship between monitoring stations. By utilizing the spatial and temporal information in graph structured data, GNN is expected to achieve more accurate water quality prediction.

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

[0006] (1) Graphing based on data correlation: This method defines the graph structure by calculating the correlation coefficients of water quality parameters between different water quality monitoring sites. When the correlation between two sites exceeds a certain threshold, it is considered that there is a connection between the two sites. Although this method can reflect the statistical characteristics of water quality data and capture the potential connections between sites, it may not fully consider the actual hydrological connections and environmental factors.

[0007] (2) Mapping based on geographic distance: This method determines whether to establish a connection based on the straight-line distance between monitoring sites. This method provides an effective means of map construction in the absence of detailed hydrological data, but it may also fail to accurately reflect the actual hydrological path and the impact of factors such as topography on the direction of water flow.

[0008] In summary, the current graph structure construction method is insufficient in capturing the real spatial relationship between water quality monitoring sites, which may lead to poor model prediction. To improve this, it is necessary to develop a new graph structure construction method that can more accurately reflect the hydrological connection between monitoring sites to enhance the model's sensitivity to spatial characteristics and improve the accuracy of prediction. This new method will bring higher reliability to water quality prediction, thereby better serving the needs of environmental protection and water resources management. Summary of the invention

[0009] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a spatiotemporal graph neural network water quality prediction method based on DEM composition. By using DEM data to extract the river network topology, a graph structure that can truly reflect the hydrological connection between monitoring sites is constructed, and the STGCN model is combined with the effective capture of spatiotemporal characteristics to effectively improve the accuracy of water quality prediction.

[0010] In order to achieve the above object, the present invention adopts the following technical solutions:

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

[0012] Obtain and process the DEM data of the target area, extract the river channel topology in the target area, and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations;

[0013] Obtain water quality data and preprocess it to eliminate the impact of missing values ​​and outliers;

[0014] A water quality prediction model is constructed based on the STGCN model, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged;

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

[0016] As a preferred technical solution, the DEM data of the target area is obtained and processed to extract the river channel topology structure in the target area, and then a graph structure reflecting the spatial relationship of water quality monitoring stations is constructed, specifically:

[0017] Obtain high-resolution DEM data of the target area, and use depression-filling processing to eliminate unnatural closed depressions in the DEM data; use hydrological analysis tools to analyze the flow direction and flow rate of the pre-processed DEM data to generate flow rate raster data, and generate preliminary river channel raster data based on the flow rate raster data and the preset catchment area threshold;

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

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

[0020] As a preferred technical solution, the hydrological analysis tool is used to analyze the flow direction and sink volume of the pre-processed DEM data, specifically:

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

[0022] In order to extract the main river flow lines, a reasonable catchment area threshold is set according to the catchment flow raster data, and the insignificant runoff paths are filtered out, leaving only the main river paths.

[0023] The conditional tool was used to binarize the flow grid to generate preliminary river channel raster data, and the connection relationship between river sections was marked by the river link tool to obtain a complete topological structure of the river network.

[0024] As a preferred technical solution, the river raster data is converted into vector line elements to generate vector data of the river network, specifically:

[0025] Use topology tools to check and correct the topology of the vector river network, eliminate hanging nodes, broken segments and repeated segments, and ensure the topological relationship of the river network is accurate;

[0026] In order to identify the main trunk and tributaries of the river, this embodiment uses the Strahler classification method to classify the rivers;

[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 the river network vector data;

[0028] Use the snap tool to snap the monitoring site to the nearest river line and set the snap tolerance to ensure that the monitoring site is accurately located on the corresponding river.

[0029] As a preferred technical solution, the graph structure reflecting the hydrological relationship of the monitoring sites is constructed based on the processed river network and monitoring site data, specifically:

[0030] Using the network analysis module, the shortest path length along the river between monitoring sites was calculated;

[0031] The weight of the edge is calculated by the following exponential decay function, that is, the weight of the edge decreases exponentially as the flow length increases. The formula is:

[0032]

[0033] Where: (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 all edge distances, and λ is the decay rate parameter.

[0034] As a preferred technical solution, the water quality data is obtained and preprocessed to eliminate the influence of missing values ​​and outliers, specifically:

[0035] Lagrange interpolation method is used to handle missing values;

[0036] The data were smoothed using the exponentially weighted moving average method;

[0037] All data are normalized to the interval [0,1] to ensure that different features are processed and analyzed at 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 of each monitoring point at a certain time as:

[0040]

[0041] Where: N represents the number of monitoring sites, C is the input node feature dimension;

[0042] The entire river basin is regarded as a graph, the water quality monitoring stations are regarded as nodes in the graph, and the connections between water stations along the river are regarded as edge connections between nodes in the graph. The dynamic graph expands the original graph structure by adding the time dimension. The graph structure at each time remains unchanged. By changing the attributes of each vertex, the impact of time changes on water quality can be better analyzed. In this way, a graph G reflecting the relationship between stations is constructed:

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

[0044] Where V is the node vector of each site, E is the edge vector of the edge connecting each site, and A is the adjacency matrix of the graph. The adjacency matrix formula is:

[0045]

[0046] In summary, the problem of predicting the entire water quality index is defined as:

[0047]

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

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

[0050]

[0051] Where: v l+1 and v l are the output and input of layer l, respectively. and They are the temporal convolution kernels used for the lower and upper layers within the block, respectively;

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

[0053]

[0054] Where: *T represents the temporal convolution operation, Y is the input feature matrix, P and Q are matrices representing the result of the convolution kernel Γ on the input Y, respectively representing the two input parts of the gated unit GLU, σ(Q) is the result of Q after being processed by the sigmoid function, and ⊙ represents the Hadamard product;

[0055] The formula of the spatial graph convolution layer is:

[0056]

[0057] Where: Θ *G Indicates the application of convolution kernel to graph data, x is the input feature matrix, θ is the convolution kernel parameter, I n is the identity matrix, with the same dimension as the number of nodes in the graph, D is the degree matrix, and W is the weighted adjacency matrix of the graph.

[0058] In a second aspect, the present invention provides a spatiotemporal graph neural network water quality prediction system based on DEM composition, which is applied to the spatiotemporal graph neural network water quality prediction method based on DEM composition, 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 obtain and process the DEM data of the target area, extract the river channel topology in the target area, and then construct a graph structure reflecting the spatial relationship of the water quality monitoring stations;

[0060] The water quality data preprocessing module is used to obtain water quality data and perform preprocessing 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, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged;

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

[0063] In a third aspect, 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, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the spatiotemporal graph neural network water quality prediction method based on DEM composition.

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

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

[0069] Fully utilize spatial and temporal features: The STGCN model of the present invention effectively combines spatial graph convolution and temporal convolution, and can simultaneously capture the spatial dependency and temporal dynamics of water quality data.

[0070] Enhance the generalization ability of the model: The graph structure construction method based on physical geographic information in the present invention makes the model more applicable in different water environments and reduces the dependence on professionals to adjust parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0072] Figure 1 It is a flow chart of a method for predicting water quality using a spatiotemporal graph neural network based on DEM composition according to an embodiment of the present invention;

[0073] Figure 2 A schematic diagram of extracting river network information according to an embodiment of the present invention;

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

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

[0076] Figure 5 4 is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0077] In order 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 in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0078] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may 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 terrain elevation of the earth's surface in digital form, usually in the form of a regular grid, with each pixel representing the altitude of the surface.

[0082] GNN (Graph Neural Network): A neural network model that can directly process graph structured data and is suitable for analyzing non-Euclidean spatial data with complex relationships between nodes.

[0083] STGCN (Spatio-Temporal Graph Convolutional Network): A deep learning model that combines temporal convolution and spatial graph convolution to process graph-structured data with spatiotemporal dependencies and capture spatial and temporal features in the data.

[0084] CNN (Convolutional Neural Network): Convolutional neural network. Mainly used to process Euclidean space data with grid structure, such as images and videos.

[0085] LSTM (Long Short-Term Memory): A recurrent neural network that can learn long-term dependencies and is good at processing sequence data.

[0086] GRU (Gated Recurrent Unit): A gated recurrent unit. A recurrent neural network similar to LSTM, with a simpler structure and the ability to capture temporal dependencies in sequence data.

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

[0088] MSE (Mean Squared Error): Mean square error. A loss function used to measure the difference between the model's predicted value and the true value. The smaller the value, the better the model performance.

[0089] MAE (Mean Absolute Error): Mean absolute error. An indicator that evaluates the average absolute difference between the predicted value and the true value.

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

[0091] MAPE (Mean Absolute Percentage Error): Mean absolute percentage error. It expresses the average relative error between the predicted value and the true value in percentage form.

[0092] R 2Coefficient of Determination: An indicator used to evaluate the degree of model fit. The value is between 0 and 1. The closer it is to 1, the better the model fit.

[0093] D8 algorithm (Deterministic 8-node algorithm): Deterministic eight-node algorithm. It is used to calculate the water flow direction of each pixel in the raster DEM data, assuming that the water flow can only flow to one of the eight adjacent pixels.

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

[0095] ReLU (Rectified Linear Unit): A commonly used activation function that outputs the maximum value of the input value and zero, introduces nonlinear characteristics, and solves the gradient vanishing problem in neural networks.

[0096] 2. Definition of key terms:

[0097] River network topology:

[0098] The structure that describes the connection between river sections in a river network reflects the spatial layout of the river and the flow path. The river network topology is used to simulate the transmission process of water flow in the river network and is the basis of hydrological models and environmental predictions.

[0099] Flow direction raster data:

[0100] Raster data representing the water flow direction of each pixel in the raster DEM data. The flow direction determines which adjacent pixel the water flows from the current pixel to. Commonly used flow direction encoding methods include the D8 algorithm.

[0101] Flow grid data:

[0102] Raster data representing the catchment area or accumulated water flow of each grid cell. The catchment volume is used to identify the location and size of the river. The larger the catchment volume, the more water accumulated upstream at that location.

[0103] Strahler classification:

[0104] A method of classifying river networks. Classes are assigned according to the confluence of rivers. When two rivers of the same level merge, the level of their downstream section increases by one. A higher level indicates a larger river. This method is often used in river network analysis and hydrological research.

[0105] Exponential decay function:

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

[0107] Weighted adjacency matrix:

[0108] In a graph structure, a matrix is ​​used to represent the connection relationship between nodes. The elements of the matrix represent the weights of the edges between nodes, reflecting the strength or distance of the connection between nodes. The weighted adjacency matrix is ​​the basis of the graph convolution operation.

[0109] Gated Convolutional Unit:

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

[0111] Activation function:

[0112] The nonlinear transformation function in the neural network is used to introduce nonlinear characteristics and enhance the expressiveness of the model. Commonly used activation functions include ReLU, Sigmoid, Tanh, etc.

[0113] Hadamard product:

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

[0115] Network Analysis:

[0116] In geographic information systems, methods used to analyze network structures (such as roads, rivers, etc.), including shortest path calculation, flow distribution, accessibility analysis, etc., are widely used in transportation planning, water resources management and other fields.

[0117] Snap Tool:

[0118] In GIS software, a tool used to accurately locate spatial elements such as points, lines, and surfaces on other spatial elements. By setting the snapping tolerance, the topological relationship of the data is ensured to be correct and errors in spatial analysis can be avoided.

[0119] Lagrange interpolation method:

[0120] A numerical analysis method that constructs a polynomial interpolation function from known data points to estimate the value of unknown data points. It is often used to deal with missing data and data smoothing.

[0121] Exponentially Weighted Moving Average (EWMA):

[0122] A smoothing method for time series data. It gives exponentially decreasing weights to historical data, with newer data points having higher weights. This can effectively reduce random noise and capture data trends.

[0123] like Figure 1 As shown, this embodiment provides a water quality prediction method based on a spatiotemporal graph neural network of DEM composition, comprising 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 digital elevation model (DEM). Geographic Information System (GIS) technology is mainly used to process DEM data, extract the river channel topology structure in the study area (i.e., the target area), and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations. DEM is a model that represents the elevation of the surface terrain in digital form. It expresses the surface elevation distribution through regular grids or irregular triangular grids. Each pixel represents the altitude of a specific location. It is the basic data for terrain analysis and hydrological simulation.

[0126] Furthermore, the specific steps of graph structure construction 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 of river network extraction. In view of the possible noise and data missing problems in the original DEM data, the unnatural closed depressions in the terrain data are eliminated by filling processing to avoid the generation of erroneous watershed points in the flow direction calculation.

[0128] Furthermore, based on the preprocessed DEM data, the hydrological analysis tools of ArcGIS were used to perform flow direction and flow analysis. The D8 algorithm was used to calculate the flow direction of each pixel to generate flow direction raster data, and then the catchment area of ​​each pixel was calculated to generate flow raster data. In order to extract the main river flow lines, a reasonable catchment area threshold was set according to the flow raster data, and the insignificant runoff paths were filtered out, leaving only the main river paths. Then, the conditional tool was used to binarize the flow raster to generate preliminary river raster data, and the river link tool was used to mark the connection relationship between river sections to ensure the integrity of the topological structure of the river network.

[0129] S12. Convert the river raster data into vector line features to generate vector data of the river network, such as Figure 2As shown in parts (a) and (b) of the figure. Use topology tools to check and correct the topology of the vector river network, eliminate hanging nodes, broken segments and repeated segments, and ensure that the topological relationship of the river network is accurate. In order to identify the main trunk and tributaries of the river, this embodiment uses the Strahler classification method to classify the rivers. Subsequently, the geographic coordinates and related attribute information of the water quality monitoring stations in the study area are collected, and the monitoring stations are imported into ArcGIS for spatial superposition with the river network vector data. Use the snap tool to snap the monitoring station to the nearest river line, and set the snap tolerance to 30 meters to ensure that the monitoring station is accurately located on the corresponding river channel.

[0130] S13. Based on the processed river network and monitoring site data, a graph structure reflecting the hydrological relationship of the monitoring sites is constructed. The nodes in the graph represent water quality monitoring sites, and the edges represent the river connections between the sites. In order to quantify the hydrological impact between monitoring sites, the weight of the edge is calculated mainly considering the flow length along the actual river. Using the network analysis module, the shortest path length along the river between monitoring sites is calculated. The weight of the edge is calculated using the following exponential decay function, that is, the weight of the edge decreases exponentially with the increase of the flow length. The formula is:

[0131]

[0132] Where: (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 all edge distances, and λ is the decay rate parameter.

[0133] The graph structure constructed in this way can more accurately reflect the hydrological relationship between the monitoring points, thereby enhancing the model's sensitivity to spatial connections when predicting water quality changes. In addition, this method also allows the model to pay more attention to nodes that are spatially close to the current node, while naturally reducing the influence of nodes that are farther away.

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

[0135] It is understandable that the water quality data obtained have some missing values ​​and outliers. To ensure the integrity and quality of the data, the Lagrange interpolation method is used to process the missing values. In addition, in order to reduce random fluctuations and noise in the data, the exponentially weighted moving average method is used to smooth the data. At the same time, the data units and orders of magnitude of each monitoring indicator are different. In order to eliminate the dimensional differences and avoid interference with model training, all data are normalized. Each data is normalized to the interval [0,1] to ensure that different features are processed and analyzed on the same scale.

[0136] The normalization formula is:

[0137]

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

[0139] S3, construct water quality prediction model based on STGCN model;

[0140] Step S3 is specifically as follows:

[0141] Define the input of each monitoring point at a certain time as:

[0142]

[0143] Where: N represents the number of monitoring sites, and C is the input node feature dimension.

[0144] The entire river basin is considered as a graph, the water quality monitoring stations are considered as nodes in the graph, and the connections between water stations along the river are considered as edge connections between nodes in the graph. The dynamic graph expands the original graph structure by adding the time dimension. The graph structure at each time remains unchanged, and the impact of time changes on water quality can be better analyzed by changing the attributes of each vertex. In this way, a graph G that reflects the relationship between stations is constructed:

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

[0146] Where V is the node vector of each site, E is the edge vector of the edge connecting each site, and A is the adjacency matrix of the graph. The adjacency matrix formula is:

[0147]

[0148] In summary, the problem of predicting the entire water quality index is defined as:

[0149]

[0150] Where: represents the predicted output of the model, H represents the length of the model input time window, 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 convolution block includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer, which are set in sequence. The model uses this "sandwich" structure to effectively mine spatial and temporal features.

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

[0153]

[0154] Where: v l+1 and v l are the output and input of layer l, respectively. and They are the temporal convolution kernels for the lower and upper layers within the block, respectively.

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

[0156]

[0157] Where: *T represents the temporal convolution operation, Y is the input feature matrix, P and q are matrices representing the result of the convolution kernel Γ on the input Y, respectively representing the two input parts of the gated unit GLU, σ(Q) is the result of Q after being processed by the sigmoid function, and ⊙ represents the Hadamard product.

[0158] The formula of the spatial graph convolution layer is:

[0159]

[0160] Where: Θ *G Indicates the application of convolution kernel to graph data, x is the input feature matrix, θ is the convolution kernel parameter, I n is the identity matrix, with the same dimension 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. The water quality to be tested is tested based on the constructed water quality prediction model. This embodiment improves the accuracy of water quality prediction by capturing the spatial dependency between water quality monitoring sites. By using DEM data to extract the river network topology, a graph structure that can truly reflect the hydrological connection between monitoring sites is constructed, and the STGCN model is combined with the effective capture of spatiotemporal characteristics to effectively improve the accuracy of water quality prediction.

[0162] In one embodiment, the technical solution of the present invention is further described by taking the main rivers in Guangzhou as an example, and selecting 9 water quality monitoring stations in the study area. The monitoring indicators include 4 water quality parameters including dissolved oxygen content, pH value, permanganate content and total phosphorus content.

[0163] The water quality monitoring data used in this example comes from the National Surface Water Quality Automatic Monitoring System. The water quality monitoring data of 9 stations in the study area are collected from November 3, 2022 to December 25, 2023. The sampling frequency is once every 4 hours, and a total of 2510 sets of data are obtained. To ensure the effectiveness of model training, the data set is divided into training set, validation set, and test set in chronological order with a ratio of 3:1:1.

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

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

[0166]

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

[0168] According to the prediction problem, the historical water quality data of the past 18 time steps (i.e. the past 72 hours) of the 9 stations are used to predict the dissolved oxygen values ​​of all 9 stations in 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. In order to reduce the impact of randomness, the model was trained independently 5 times, and the average of the 5 experimental results was taken as the experimental result.

[0169] After training, the model is evaluated on the test set using a variety of evaluation metrics to comprehensively assess the model’s 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 MAE, RMSE, and MAPE values ​​are, the larger the R2 value is, which means the better the model is in the prediction task.

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

[0171] Table 2 Comparison of prediction performance of the proposed model and other comparison models

[0172]

[0173] The experimental results show that the STGCN model based on DEM composition proposed in this embodiment outperforms other models in all evaluation indicators and shows the best prediction performance. When the STGCN models with different composition methods are compared with the traditional GCN, GRU, LSTM and MLP models, they all have certain advantages, which shows that the model based on spatiotemporal graph neural network has certain advantages in capturing spatial dependencies.

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

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

[0176] See also Figure 4 In another embodiment of the present application, a spatiotemporal graph neural network water quality prediction system 100 based on DEM composition is provided, the system comprising a DEM data processing module 101, a water quality data preprocessing module 102, a water quality prediction model building module 103 and a water quality prediction module 104;

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

[0178] The water quality data preprocessing module 102 is used to obtain water quality data and preprocess it to eliminate the influence of missing values ​​and abnormal values;

[0179] The water quality prediction model 103 is used to construct a water quality prediction model based on the STGCN model, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged;

[0180] The water quality prediction module 104 detects the water quality to be detected 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 composition of the present invention corresponds one-to-one to the spatiotemporal graph neural network water quality prediction method based on DEM composition of the present invention. The technical features and beneficial effects described in the embodiment of the spatiotemporal graph neural network water quality prediction method based on DEM composition are applicable to the embodiment of the spatiotemporal graph neural network water quality prediction based on DEM composition. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here.

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

[0183] See also Figure 5 In one embodiment, an electronic device for implementing a spatiotemporal graph neural network water quality prediction method based on DEM composition is provided. 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 composition.

[0184] Among them, the first memory 202 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the first memory 202 can be an internal storage unit of the electronic device 200, such as a mobile hard disk 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 mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 200. Further, the first memory 202 can also include both an internal storage unit of the electronic device 200 and an external storage device. The first memory 202 can not only be used to store application software and various types of data installed in the electronic device 200, such as the code of the spatiotemporal graph neural network water quality prediction program 203 based on DEM composition, but also can be used to temporarily store data that has been output or is to be output.

[0185] In some embodiments, the first processor 201 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips, etc. The first processor 201 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes various functions and processes data of the electronic device 200 by running or executing programs or modules stored in the first memory 202, and calling data stored in the first memory 202.

[0186] Figure 5 Only an electronic device with components is shown, and those skilled in the art will understand 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 in the figure, or combine certain components, or arrange the components differently.

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

[0188] Obtain and process the DEM data of the target area, extract the river channel topology in the target area, and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations;

[0189] Obtain water quality data and preprocess it to eliminate the impact of missing values ​​and outliers;

[0190] A water quality prediction model is constructed based on the STGCN model, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged;

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

[0192] Furthermore, if the module / unit integrated in the electronic device 200 is implemented in the form of a software functional unit and sold or used as an independent product, it 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 mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0193] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0194] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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 implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A spatiotemporal graph neural network water quality prediction method based on DEM composition, characterized in that: The steps include: Obtain and process the DEM data of the target area, extract the river channel topology in the target area, and then construct a graph structure reflecting the spatial relationship of water quality monitoring stations; Obtain water quality data and preprocess it to eliminate the impact of missing values ​​and outliers; A water quality prediction model is constructed based on the STGCN model, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged; The water quality to be tested is tested based on the constructed water quality prediction model.

2. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 1 is characterized in that: The DEM data of the target area is obtained and processed to extract the river channel topology structure in the target area, and then a graph structure reflecting the spatial relationship of water quality monitoring stations is constructed, specifically: Obtain high-resolution DEM data of the target area, and use depression-filling processing to eliminate unnatural closed depressions in the DEM data; use hydrological analysis tools to analyze the flow direction and flow rate of the pre-processed DEM data to generate flow rate raster data, and generate preliminary river channel raster data based on the flow rate raster data and the preset catchment area threshold; Convert river raster data into vector line features to generate vector data of river network; Based on the processed river network and monitoring site data, a graph structure reflecting the hydrological relationship of the monitoring sites is constructed. The nodes in the graph structure represent water quality monitoring sites, and the edges represent the river connections between the sites.

3. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 2 is characterized in that: The hydrological analysis tools used are used to analyze the flow direction and sink volume of the preprocessed DEM data, specifically: The D8 algorithm is used to calculate the water flow direction of each pixel, generate flow direction raster data, and then calculate the catchment area of ​​each pixel to generate catchment flow raster data; In order to extract the main river flow lines, a reasonable catchment area threshold is set according to the catchment flow raster data, and the insignificant runoff paths are filtered out, leaving only the main river paths. The conditional tool was used to binarize the flow grid to generate preliminary river channel raster data, and the connection relationship between river sections was marked by the river link tool to obtain a complete topological structure of the river network.

4. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 2 is characterized in that: The process of converting the river raster data into vector line elements to generate the vector data of the river network is as follows: Use topology tools to check and correct the topology of the vector river network, eliminate hanging nodes, broken segments and repeated segments, and ensure the topological relationship of the river network is accurate; In order to identify the main trunk and tributaries of the river, this embodiment uses the Strahler classification method 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 the river network vector data; Use the snap tool to snap the monitoring site to the nearest river line and set the snap tolerance to ensure that the monitoring site is accurately located on the corresponding river.

5. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 2 is characterized in that: The graph structure reflecting the hydrological relationship of the monitoring stations is constructed based on the processed river network and monitoring station data, specifically: Using the network analysis module, the shortest path length along the river between monitoring sites was calculated; The weight of the edge is calculated by the following exponential decay function, that is, the weight of the edge decreases exponentially as the flow length increases. The formula is: Where: (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 all edge distances, and λ is the decay rate parameter.

6. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 1 is characterized in that: The water quality data is obtained and preprocessed to eliminate the influence of missing values ​​and outliers, specifically: Lagrange interpolation method is used to handle missing values; The data were smoothed using the exponentially weighted moving average method; All data are normalized to the interval [0,1] to ensure that different features are processed and analyzed at the same scale.

7. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 1 is characterized in that: In the step of constructing a water quality prediction model based on the STGCN model, Define the input of each monitoring point at a certain time as: Where: N represents the number of monitoring sites, C is the input node feature dimension; The entire river basin is regarded as a graph, the water quality monitoring stations are regarded as nodes in the graph, and the connections between water stations along the river are regarded as edge connections between nodes in the graph. The dynamic graph expands the original graph structure by adding the time dimension. The graph structure at each time remains unchanged. By changing the attributes of each vertex, the impact of time changes on water quality can be better analyzed. In this way, a graph G reflecting the relationship between stations is constructed: G t =(V t ,E,A) Where V is the node vector of each site, E is the edge vector of the edge connecting each site, and A is the adjacency matrix of the graph. The adjacency matrix formula is: In summary, the problem of predicting the entire water quality index is defined as: Where: represents the predicted output of the model, H represents the length of the model input time window, and f represents the water quality prediction model.

8. The water quality prediction method based on spatiotemporal graph neural network of DEM composition according to claim 1 is characterized in that: The formula for each spatiotemporal convolution block is: Where: v l+1 and v l are the output and input of layer l, respectively. and They are the temporal convolution kernels used for the lower and upper layers within the block, respectively; The formula of the time-gated convolutional layer is: Where: *T represents the temporal convolution operation, Y is the input feature matrix, P and Q are matrices representing the result of the convolution kernel Γ on the input Y, respectively representing the two input parts of the gated unit GLU, σ(Q) is the result of Q after being processed by the sigmoid function, and ⊙ represents the Hadamard product; The formula of the spatial graph convolution layer is: Where: Θ *G Indicates the application of convolution kernel to graph data, x is the input feature matrix, θ is the convolution kernel parameter, I n is the identity matrix, with the same dimension as the number of nodes in the graph, D is the degree matrix, and W is the weighted adjacency matrix of the graph.

9. The spatiotemporal graph neural network water quality prediction system based on DEM composition is characterized by: The spatiotemporal graph neural network water quality prediction method based on DEM composition applied to any one of claims 1-8 comprises 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 obtain and process the DEM data of the target area, extract the river channel topology in the target area, and then construct a graph structure reflecting the spatial relationship of the water quality monitoring stations; The water quality data preprocessing module is used to obtain water quality data and perform preprocessing 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, wherein the STGCN model includes a plurality of spatiotemporal convolution blocks, each of which includes a time-gated convolution layer, a spatial graph convolution layer, and a time-gated convolution layer that are sequentially arranged; The water quality prediction module detects the water quality to be detected based on the constructed water quality prediction model.

10. An electronic device, characterized in that: The electronic device comprises: 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, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the spatiotemporal graph neural network water quality prediction method based on DEM composition as described in any one of claims 1-8.

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

Cited By

  • Loss function optimization method based on graph neural network in spatial data processing

    CN120409591A

  • Inlet water quality prediction method and device, electronic equipment and storage medium

    CN120782074A

  • Inlet water quality prediction method and device, electronic equipment and storage medium

    CN120782074B

  • River water quality prediction method and system considering spatial information accumulation

    CN121093799A

  • Network traffic prediction method and device, electronic equipment and storage medium

    CN121125529A