A small and medium-sized basin flood intelligent prediction method based on a Transformer-Unet architecture

CN123013025APending Publication Date: 2026-10-30STATE QIHOU CENT +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611216842.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-12
Publication Date
2026-10-30

AI Technical Summary

Benefits of technology

多通道输入张量形成后,对规则网格系统中的每一个网格单元,提取其自身及空间邻域内各网格单元的多通道特征向量,并计算目标单元与各邻域单元特征向量之间的向量内积,得到多个空间关联原始度量值;再对这些度量值执行柔性最大值归一化运算,生成第一关联权重矩阵中对应的关联权重值。该权重矩阵直接体现了每对网格单元之间数据驱动的空间依赖程度,突破了固定邻域卷积操作只能提取局部一致结构的局限。得到权重矩阵后,以每一个网格单元作为目标加权单元,提取其多个邻域单元的多通道特征向量,分别与对应的关联权重值进行逐元素乘法并求和,形成聚合特征向量作为流域状态空间映射值。这一重分配过程使任意两个空间位置之间均可基于数据自适应地传递信息,即使相距较远但与产汇流过程强相关的网格单元也能获得高权重响应,对中小流域内降雨落区分散、产流机制差异显著的情形,能更精细地刻画洪水时空演变,从而提升预报对降雨空间异质性的适应性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123013025A_ABST
    Figure CN123013025A_ABST
Patent Text Reader

Abstract

The application discloses a small and medium-sized basin flood intelligent forecasting method based on a Transformer-Unet architecture, and belongs to the technical field of flood intelligent forecasting. The method acquires a static underlying surface feature set of a target basin, a hydrodynamic state field at a reporting time and hourly rainfall forcing fields at multiple forecast times in the future; a regular grid system is constructed according to digital elevation data, and a flow direction index code and a confluence path topological relation of each grid unit are established; after each data dimension is normalized, the data is mapped to the grid system to form a multi-channel input tensor set; spatial correlation measurement operation based on the grid unit is performed on the tensor set to generate a first correlation weight matrix representing the spatial dependence degree between grids; and the tensor space distribution is redistributed according to the weight matrix to obtain a basin state space mapping value. The method can adaptively capture the spatial dependence relationship between grids and integrate the basin confluence prior, and the precision of flood forecasting under complex topography is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent flood forecasting technology, specifically to an intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture. Background Technology

[0002] Flood forecasting in small and medium-sized watersheds has always been a challenge in the field of hydrological forecasting due to factors such as data scarcity and complex topography. Existing flood forecasting methods mainly include process-driven hydrological models and data-driven deep learning models. Process-driven models describe runoff generation and confluence processes based on physical equations, but require a large amount of measured data to calibrate parameters, limiting their applicability in small and medium-sized watersheds with limited data. Data-driven models directly learn the mapping relationship between inputs such as rainfall and runoff output, but their characterization of spatial structure is relatively coarse. They often use fixed-size convolutional kernels to extract local features, making it difficult to adaptively model the dynamic changes of nonlinear spatial dependencies between different grid cells. This results in insufficient forecasting capability for small and medium-sized watersheds with strong spatial heterogeneity of rainfall and complex runoff paths. In addition, existing deep learning models usually process multi-channel inputs directly on regular grids, ignoring the key prior information of the watershed's inherent flow direction and runoff topology. This makes the models prone to deviating from physical laws when calculating the spatiotemporal evolution of runoff, especially with a significant decrease in accuracy as the forecast period lengthens. How to enable a model to flexibly capture the spatial relationships between arbitrary grid cells and to structurally introduce watershed hydrological topological priors into the model input under conditions of scarce data and without relying on a large number of manually designed features is an urgent problem to be solved in order to improve the accuracy of intelligent flood forecasting in small and medium-sized watersheds. Summary of the Invention

[0003] This invention provides a smart flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture, which overcomes the problems of insufficient watershed spatial dependency modeling capability and lack of hydrological topology prior utilization in the existing technology, and realizes high-precision flood forecasting applicable to small and medium-sized watersheds with scarce data.

[0004] To achieve the above objectives, this invention provides the following technical solution: This invention provides a method for intelligent flood forecasting in small and medium-sized watersheds based on the Transformer-Unet architecture. This method combines the spatial self-attention mechanism of Transformer with the multi-scale encoder-decoder structure of Unet, achieving high-resolution intelligent forecasting of flood evolution processes based on accurate characterization of the watershed confluence topology. The method includes: acquiring the static underlying surface feature set of the target watershed, the hydrodynamic state field at the forecast initiation time, and the hourly rainfall forcing field at multiple future forecast times; constructing a regular grid system for the target watershed based on the digital elevation data in the static underlying surface feature set, and establishing flow direction index encoding and confluence path topology relationships for each grid cell in the regular grid system, thereby embedding the physical laws of watershed surface water flow movement into the gridded data organization, providing reliable hydrological structure priors for subsequent models; after dimensional normalization of the hydrodynamic state field, the hourly rainfall forcing field, and the static underlying surface feature set, mapping them uniformly to the regular grid system to form a spatially aligned multi-channel input tensor set, enabling multi-source heterogeneous... Data is fused under a unified spatial reference. Spatial correlation metric operations based on grid cells are performed on the multi-channel input tensor set to generate a first correlation weight matrix that characterizes the spatial dependence between grid cells in the regular grid system. This adaptively captures the long-range and short-range dependencies of flood wave propagation between any grid cells in the watershed. Based on the first correlation weight matrix, the spatial distribution of the multi-channel input tensor set on the regular grid system is redistributed to obtain the watershed state space mapping value corresponding to the current forecast time. This mapping value serves as the deep spatial feature map output by the Unet encoder, which is further used by the decoder to recover the refined flood element forecast results. This method demonstrates outstanding performance in reducing flood peak forecast errors and spatial distribution deviations.

[0005] As a preferred technical solution of the present invention, the step of constructing a regular grid system based on digital elevation data in the static underlying surface feature set and establishing flow direction index codes and confluence path topology relationships specifically includes: using the preset center point coordinates of the target watershed as a reference point, generating a rectangular grid frame covering the target watershed according to a preset spatial resolution and number of grid rows and columns, as the regular grid system; traversing each grid cell in the regular grid system, determining the flow direction code of the grid cell based on the elevation value of the grid cell in the digital elevation data and the elevation values ​​of its eight adjacent grid cells, and using the flow direction code as the flow direction index code of the grid cell; and using a stack scan algorithm to trace the path of each grid cell along the flow direction to the preset river channel grid cell according to the flow direction index code of each grid cell, forming the confluence path topology relationship of each grid cell. Preferably, the water flow direction encoding employs the D8 single-flow-direction algorithm, determining the water flow direction encoding based on the maximum elevation gradient between the central grid cell and its eight adjacent grid cells, ensuring the topographic rationality of the determined flow direction. The stack scanning algorithm is a depth-first search algorithm, using the flow direction index encoding of each grid cell as edges to recursively trace along the water flow direction to the preset river channel grid cell, accurately forming the topological relationship of the confluence path for each grid cell. Through the above processing, the water transport path of any grid within the watershed is clearly encoded, providing explicit physical guidance for the neural network to perceive the confluence process.

[0006] As another preferred technical solution of the present invention, the step of obtaining the static underlying surface feature set of the target watershed includes: obtaining digital elevation model data, leaf area index raster data, land use type proportion raster data, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data of the target watershed; calculating slope raster data, aspect sine component raster data, aspect cosine component raster data, runoff accumulation raster data, and height above the nearest drainage channel index raster data based on the digital elevation model data; extracting river network mask raster data of the target watershed based on the digital elevation model data, and calculating the planar distance raster data from each grid cell to the nearest river channel grid cell in the regular grid system; and combining all the above raster data by channel to form the static underlying surface feature set. Preferably, the digital elevation model data, leaf area index raster data, land use type ratio raster data, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data are all derived from satellite remote sensing inversion products with a preset spatial resolution. This multi-channel static feature set comprehensively covers key factors affecting runoff generation and confluence, such as topography, vegetation, soil, and land use, enabling the model to perceive differences in runoff generation mechanisms across different underlying surfaces.

[0007] As a further preferred technical solution of the present invention, the step of uniformly mapping the hydrodynamic state field, the hourly rainfall forcing field, and the static underlying surface feature set to a regular grid system after dimensional normalization to form a spatially aligned multi-channel input tensor set specifically includes: applying linear scaling operations to the water depth component, eastward velocity component, and northward velocity component in the hydrodynamic state field to map the numerical range of each component to a preset first numerical interval to eliminate dimensional differences between different physical quantities; and performing a logarithmic transformation operation with the natural constant as the base on each rainfall grid in the hourly rainfall forcing field, followed by linear scaling operations to map the numerical range of the rainfall grid to a preset second numerical interval. The log-linear combination normalization effectively compresses the extreme peak values ​​of heavy rainfall data, improving the model's stability in depicting spatial heterogeneity of rainfall. For each raster data point in the static underlying surface feature set, linear scaling or a combination of logarithmic transformation and linear scaling is performed according to the data type of each raster data point, mapping the numerical range of each raster data point to a preset third numerical interval. The hydrodynamic state field mapped to the first numerical interval, the hourly rainfall forcing field mapped to the second numerical interval, and the static underlying surface feature set mapped to the third numerical interval are uniformly mapped to the spatial resolution and grid alignment of the regular grid system through bilinear interpolation resampling, forming the multi-channel input tensor set. Preferably, the linear scaling operation uses a minimum-maximum normalization method, subtracting the minimum value of each element in the data to be normalized and then dividing by the range of the data to achieve numerical range mapping. This normalization and alignment process ensures strict matching of multi-source data in numerical distribution and spatial location, which is the basis for obtaining effective representation in subsequent spatial correlation operations.

[0008] As a preferred embodiment, the step of performing a spatial correlation metric operation based on grid cells on the multi-channel input tensor set to generate a first correlation weight matrix includes: taking each grid cell in the regular grid system as the target center cell, extracting the multi-channel feature vector of the target center cell from the multi-channel input tensor set, and extracting the multi-channel feature vectors of each neighboring grid cell within the spatial neighborhood of the target center cell; calculating the vector inner product between the multi-channel feature vector of the target center cell and the multi-channel feature vectors of each neighboring grid cell to obtain multiple original spatial correlation metrics; and performing a flexible maximum normalization operation on the multiple original spatial correlation metrics to generate the correlation weight values ​​in the first correlation weight matrix corresponding to the correlation weight values ​​between the target center cell and each of the neighboring grid cells. This data-driven spatial attention operation allows the interaction strength between grids to be automatically learned from the data without explicit setting, effectively reflecting the anisotropic dependence caused by terrain barriers and river course.

[0009] Accordingly, the step of redistributing the spatial distribution of the multi-channel input tensor set according to the first correlation weight matrix to obtain the watershed state space mapping value includes: taking each grid cell in the regular grid system as the target weighting cell, extracting multi-channel feature vectors of multiple neighboring grid cells corresponding to the target weighting cell according to the first correlation weight matrix; performing element-wise multiplication operations on the multi-channel feature vectors of the multiple neighboring grid cells with the corresponding correlation weight values ​​in the first correlation weight matrix to obtain multiple weighted feature vectors; performing element-wise summation operations on the multiple weighted feature vectors to obtain the aggregated feature vector of the target weighting cell, and using the aggregated feature vector as the watershed state space mapping value of the grid cell. Therefore, the output of each grid cell not only contains its own hydrodynamic and attribute information, but also adaptively integrates information from neighboring and even more distant related grids, greatly enhancing the model's ability to express the spatial propagation process of floods. By inputting the above mapping values ​​into the multi-level decoding network under the Unet architecture, the water depth and flow velocity forecast fields for future moments can be reconstructed step by step. This significantly improves the forecast accuracy of flood peak arrival time, flood peak water level, and inundation range in flood forecasting of small and medium-sized river basins, and has good computational efficiency, which can meet the timeliness requirements of real-time forecasting.

[0010] The technical effects and advantages provided by the present invention in the above technical solution are as follows: After the multi-channel input tensor is formed, for each grid cell in the regular grid system, the multi-channel feature vectors of the target cell and its neighboring grid cells are extracted. The dot product between the feature vectors of the target cell and its neighboring cells is calculated to obtain multiple original spatial correlation metrics. Flexible maximum normalization is then performed on these metrics to generate the corresponding correlation weight values ​​in the first correlation weight matrix. This weight matrix directly reflects the data-driven spatial dependency between each pair of grid cells, overcoming the limitation of fixed-neighborhood convolution operations, which can only extract locally consistent structures. After obtaining the weight matrix, each grid cell is used as the target weighting cell, and the multi-channel feature vectors of its multiple neighboring cells are extracted. These feature vectors are then multiplied element-wise with the corresponding correlation weight values ​​and summed to form an aggregated feature vector as the watershed state space mapping value. This redistribution process enables information to be adaptively transferred between any two spatial locations based on data. Even grid cells that are far apart but strongly correlated with runoff generation processes can receive high-weight responses. In cases where rainfall distribution is dispersed and runoff generation mechanisms differ significantly within small and medium-sized watersheds, it can more precisely characterize the spatiotemporal evolution of floods, thereby improving the forecast's adaptability to spatial heterogeneity of rainfall.

[0011] When constructing the input structure, a regular grid system is established based on digital elevation data. The D8 single-direction algorithm is used to generate flow direction codes for each grid cell as flow direction index codes. Then, a stack scan algorithm is used to trace along the flow direction to the channel grid, forming a complete confluence path topology. This topology is essentially a directed graph structure built with grid cells as nodes and flow directions as edges, explicitly encoding the physical process of surface runoff accumulating along the topographic gradient into a computable relationship in the grid space. This structured information is retained in the multi-channel input tensor set, replacing the practice of having the deep learning model implicitly learn hydrological paths from scratch. After embedding this topology into the model's input space, subsequent spatial correlation measurements and state redistribution operations are indirectly guided by physical constraints. This makes the learning of inter-grid dependencies no longer solely dependent on statistical correlation, but rather governed by the actual watershed confluence structure, reducing the reliance on a large number of training samples. In small and medium-sized watersheds with steep terrain and dense river networks, this effectively alleviates the problem of forecast results deviating from actual flow paths, enhancing the physical rationality of forecasts and their generalization ability under data-scarce conditions. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0013] Figure 1 This is a flowchart of a smart flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture; Figure 2 This is a flowchart of the watershed raster flow direction encoding and confluence path topology construction process; Figure 3 This is a flowchart of the feature space distribution redistribution of grid cells based on the correlation weight matrix. Detailed Implementation

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

[0015] See Figure 1This invention provides a method for intelligent flood forecasting in small and medium-sized watersheds based on the Transformer-Unet architecture. The method acquires a static underlying surface feature set of the target watershed, the hydrodynamic state field at the forecast initiation time, and hourly rainfall forcing fields for multiple future forecast times. Based on the digital elevation data in the static underlying surface feature set, a regular grid system for the target watershed is constructed, and for each grid cell in the regular grid system, a flow direction index encoding and a confluence path topology are established. The hydrodynamic state field, the hourly rainfall forcing field, and the static underlying surface feature set are dimensionally normalized and then uniformly mapped onto the regular grid system, forming a spatially aligned multi-channel input tensor set. A spatial correlation metric operation based on grid cells is performed on the multi-channel input tensor set to generate a first correlation weight matrix characterizing the spatial dependence between grid cells in the regular grid system. Based on the first correlation weight matrix, the spatial distribution of the multi-channel input tensor set on the regular grid system is redistributed to obtain the watershed state space mapping value corresponding to the current forecast time.

[0016] In specific implementation, please refer to Figure 2 The preset center point coordinates of the target watershed are pre-set based on the geographical location of the watershed, for example, using the coordinates corresponding to the geometric center of the watershed or the control section of a hydrological station as the preset center point coordinates. The preset spatial resolution is expressed as... The unit is meters. The preset spatial resolution is set based on the original resolution of the available digital elevation data and an assessment of computing resources. The preset spatial resolution value is consistent with the original spatial resolution of the digital elevation data or set to an integer multiple of the original spatial resolution. The number of grid rows and columns includes the number of grid rows. and the number of grid columns The number of grid rows and columns is calculated based on the north-south and east-west spans of the target watershed and the preset spatial resolution. The north-south span is divided by the preset spatial resolution to obtain the integer part of the number of grid rows, which is then rounded up. Similarly, the east-west span is divided by the preset spatial resolution to obtain the integer part of the number of grid columns, which is also rounded up. Using the preset center point coordinates as a reference point, and combining the number of grid rows, the number of grid columns, and the preset spatial resolution, the starting point coordinates of the rectangular grid frame are calculated. Starting from the starting point coordinates, grid points are generated in the horizontal and vertical directions with a step size of the preset spatial resolution, forming a rectangular grid frame covering the target watershed. This rectangular grid frame serves as a regular grid system. Each grid cell in the rectangular grid frame is a square region, and the center point coordinates of each grid cell are uniquely determined by the grid row number and the grid column number.

[0017] After generating the regular grid system, the flow direction index encoding is established by traversing each grid cell in the regular grid system. For each traversed grid cell, its elevation value in the digital elevation data is obtained, along with the elevation values ​​of its eight neighboring grid cells in the regular grid system. The eight neighboring grid cells are those adjacent to the traversed grid cell in the horizontal, vertical, and diagonal directions. Using the D8 unidirectional flow algorithm, the elevation gradient is calculated based on the elevation values ​​of the traversed grid cell and its eight neighboring grid cells. The formula for calculating the elevation gradient is:

[0018] in, Indicates the direction index of the traversed grid cell. elevation gradient, The value of is an integer from 0 to 7, corresponding to the eight directions: east, southeast, south, southwest, west, northwest, north, and northeast. This represents the elevation value of the grid cell being traversed; This indicates the orientation index of the traversed grid cell. The elevation value of the adjacent grid cell; This indicates the traversed grid cell and its direction index. The distance between the center points of adjacent grid cells, when the direction index is used. When it is east, south, west, or north, Equal to the preset spatial resolution When direction index When it is southeast, southwest, northwest, or northeast, Equal to the preset spatial resolution Multiply .

[0019] After calculating the elevation gradients of the traversed grid cells along eight directions, determine the maximum value among all elevation gradients and the direction index corresponding to the maximum elevation gradient. The water flow direction code is determined as the traversed grid cell, and the water flow direction code is an integer value between 0 and 7. The obtained water flow direction code is used as the flow direction index code of the traversed grid cell, and the correspondence between the flow direction index code and the traversed grid cell is recorded.

[0020] In some embodiments, if the elevation value of the traversed grid cell is lower than the elevation values ​​of all eight adjacent grid cells, it indicates that the grid cell is a local depression and the water flow direction cannot be determined based on the elevation gradient. In this case, the flow direction index of the traversed grid cell is encoded as a preset special marker value, and the preset special marker value is not in the range of 0 to 7.

[0021] After traversing each grid cell in the regular grid system and establishing the flow direction index code, the confluence path topology is constructed based on the flow direction index code of each grid cell. The construction of the confluence path topology adopts the stack scan algorithm, which is a depth-first search algorithm. In specific implementation, the preset river channel grid cells are determined by marking the grid cells belonging to the river channel location in the river network mask raster data in the static underlying surface feature set as preset river channel grid cells.

[0022] Using each grid cell in the regular grid system as the starting grid cell, a stack scan algorithm is executed. An empty stack is initialized for the starting grid cell, and its grid identifier is pushed onto the stack. The flow direction index code of the starting grid cell is obtained, and its downstream grid cells are determined based on this code. If the flow direction index code of the starting grid cell is a preset special marker value, the tracking of the starting grid cell is terminated. If the downstream grid cell of the starting grid cell belongs to a preset river channel grid cell, the grid identifier of the starting grid cell is pushed onto the stack, the tracking is terminated, and the path recorded in the current stack is saved as the confluence path topology of the starting grid cell. If the downstream grid cell of the starting grid cell does not belong to a preset river channel grid cell and does not exceed the boundary of the regular grid system, the downstream grid cell is pushed onto the stack as the currently tracked grid cell, and the flow direction index code of the currently tracked grid cell is obtained, recursively tracking along the flow direction. During the recursive tracking process, if the flow direction index code of the currently tracked grid cell points to an existing grid cell in the stack, it indicates a confluence loop has occurred; the tracking is terminated, and the confluence path of that starting grid cell is marked as invalid. Using a stack scanning algorithm, the flow direction index of each grid cell is encoded as an edge, and the flow direction is recursively traced to the preset river channel grid cell, forming the topological relationship of the confluence path of each grid cell. The topological relationship of the confluence path is represented by the sequence of grid cells that each grid cell passes through to the preset river channel grid cell.

[0023] In practice, the following data are acquired for the target watershed: digital elevation model (DEM) data, leaf area index (LAI) raster data, land use type percentage raster data, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data. All of these data are derived from satellite remote sensing inversion products with a preset spatial resolution. The spatial resolution of the satellite remote sensing inversion products is consistent with the preset spatial resolution of the regular grid system, or the spatial resolution of the satellite remote sensing inversion products with the preset spatial resolution is higher than the preset spatial resolution of the regular grid system. When the spatial resolution of the satellite remote sensing inversion products is inconsistent with the preset spatial resolution of the regular grid system, the satellite remote sensing inversion product data is resampled to the preset spatial resolution of the regular grid system using a bilinear interpolation resampling method.

[0024] Based on digital elevation model data, calculate slope raster data, aspect sine component raster data, aspect cosine component raster data, runoff accumulation raster data, and index data of height above the nearest drainage channel.

[0025] The slope raster data is calculated as follows: for each grid cell in the digital elevation model data, the elevation value within a 3×3 moving window centered on that grid cell is used, and the rate of elevation change of that grid cell in the east-west direction is estimated using a third-order inverse distance squared weighted difference algorithm. and the rate of change of elevation in the north-south direction Then calculate the slope value using the following formula:

[0026] in, In a regular grid system, the first Line 1 The slope value of the column grid cells, in radians; In a regular grid system, the first Line 1 The rate of elevation change of the column grid cells in the east-west direction, through the first Line 1 The elevation values ​​of the adjacent grid cells on the west side and the adjacent grid cells on the east side within the 3×3 moving window containing the column grid cell are obtained by weighted difference calculation. In a regular grid system, the first Line 1 The rate of elevation change of the column grid cells in the north-south direction, through the first Line 1 The slope value is calculated by weighted difference between the elevation values ​​of the adjacent grid cells on the north side and the adjacent grid cells on the south side within the 3×3 moving window containing the column grid cell. After calculating the slope value of each grid cell, the slope value is converted from radians to degrees to form slope raster data covering the entire regular grid system.

[0027] The sine and cosine aspect raster data are calculated based on the aspect angle. The aspect angle represents the clockwise angle between the projection direction of the slope normal onto the horizontal plane and the true north direction. The east-west elevation change rate of each grid cell is obtained using a third-order inverse distance squared weighted difference algorithm. and the rate of change of elevation in the north-south direction The aspect angle is calculated using the arctangent function, with a value ranging from 0 to 360 degrees. The sine value of the aspect angle is used as the sine component and assigned to the corresponding grid cell to form the sine component raster data; the cosine value of the aspect angle is used as the cosine component and assigned to the corresponding grid cell to form the cosine component raster data.

[0028] The runoff accumulation raster data reflects the upstream catchment area of ​​each grid cell. The D-infinity multi-flow direction algorithm is used to calculate the runoff accumulation raster data. Based on digital elevation model data, the D-infinity multi-flow direction algorithm determines the direction of maximum slope and calculates the flow direction distribution angle within a 3×3 moving window, centered on each grid cell. It then distributes the water flow of each grid cell to one or two adjacent downstream grid cells according to the slope ratio. After completing the flow direction distribution across the entire watershed, starting from the watershed boundary grid cell, the number of grid cells contributing to the runoff accumulation is recursively accumulated along the flow direction from upstream to downstream. The accumulated result is used as the runoff accumulation of each grid cell, forming the runoff accumulation raster data.

[0029] The calculation of the height above the nearest drainage channel index raster data relies on digital elevation model data and river network mask raster data. The extraction process for the river network mask raster data is as follows: based on the runoff accumulation raster data, a runoff accumulation threshold of 500 is set. Grid cells with a runoff accumulation greater than or equal to 500 are marked as river channel grid cells and assigned a first label value; grid cells with a runoff accumulation less than 500 are marked as non-river channel grid cells and assigned a second label value, thus generating the river network mask raster data. The runoff accumulation threshold of 500 is based on the fact that, through hydrological path analysis of small and medium-sized watersheds, when the runoff accumulation reaches 500 upstream grid cells, the resulting path exhibits continuous flow characteristics and can be identified as a river channel.

[0030] After acquiring the river network mask raster data, for each grid cell in the digital elevation model data, the nearest river channel grid cell is determined, and the difference between the elevation value of the grid cell and the elevation value of the nearest river channel grid cell is calculated. This difference is used as the index of the height of the grid cell being higher than the nearest drainage channel, forming raster data of the height being higher than the nearest drainage channel index.

[0031] The calculation of planar distance raster data utilizes river network mask raster data and is implemented through an Euclidean distance transformation algorithm. For each grid cell in the regular grid system, the Euclidean distance transformation algorithm calculates the Euclidean planar distance from the center point of that grid cell to the center point of the nearest river channel grid cell. The calculated distance value is used as the planar distance value of that grid cell, and the planar distance values ​​of all grid cells constitute the planar distance raster data.

[0032] After completing the calculations for all derived raster data, the digital elevation model data, leaf area index raster data, land use type proportion raster data, soil sand content raster data, soil clay content raster data, soil organic matter content raster data, slope raster data, aspect sine component raster data, aspect cosine component raster data, runoff accumulation raster data, height above nearest drainage channel index raster data, river network mask raster data, and planar distance raster data are combined by channel to form a static underlying surface feature set. Combining by channel means treating each type of raster data as an independent data channel. All raster data are spatially aligned at the grid cell positions in the regular grid system and stacked along the channel dimension to form a set with dimensions [number of channels, number of grid rows]. , the number of grid columns The data is a three-dimensional array with 13 channels. The channels are arranged in the following order: digital elevation model data channel, leaf area index raster data channel, land use type proportion raster data channel, soil sand content raster data channel, soil clay content raster data channel, soil organic matter content raster data channel, slope raster data channel, aspect sine component raster data channel, aspect cosine component raster data channel, runoff accumulation raster data channel, height above nearest drainage channel index raster data channel, river network mask raster data channel, and planar distance raster data channel.

[0033] In some embodiments, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data are all stored as mass percentages, with values ​​ranging from 0 to 100; land use type proportion raster data represent the area ratio of each land use type within each grid cell, with values ​​ranging from 0 to 1; leaf area index raster data are dimensionless values, with values ​​conforming to the typical range of satellite remote sensing inversion products. These raster data retain their original numerical form when participating in channel compositing.

[0034] In practical implementation, the hydrodynamic state field includes a water depth component, an eastward velocity component, and a northward velocity component. The water depth component represents the field formed by the difference between the elevation of the upper surface and the bottom elevation of each grid cell, in meters. The eastward velocity component represents the field formed by the flow velocity of the water in each grid cell along the due east direction, in meters per second. The northward velocity component represents the field formed by the flow velocity of the water in each grid cell along the due north direction, in meters per second. Linear scaling operations are applied to the water depth component, the eastward velocity component, and the northward velocity component to map the numerical range of each component to a preset first numerical interval. The linear scaling operation uses a minimum-maximum normalization formula, subtracting the minimum value of the data to be normalized from each element value in the data to be normalized, and then dividing by the range of the data to be normalized to achieve numerical range mapping. The calculation formula is as follows:

[0035] in, This indicates the water depth component, the eastward velocity component, or the northward velocity component in the [missing information]. Line 1 The normalized result obtained after linear scaling of column grid cells; This indicates the water depth component, the eastward velocity component, or the northward velocity component in the [missing information]. Line 1 The original values ​​of the column grid cells; This represents the minimum original value of the water depth component, the eastward velocity component, or the northward velocity component across all grid cells covered by the regular grid system. This represents the maximum original value of the water depth component, the eastward velocity component, or the northward velocity component across all grid cells covered by the regular grid system. This represents the lower boundary value of the preset first numerical interval; This represents the upper boundary value of the preset first numerical interval. The preset first numerical interval is set to [0,1], i.e. The value is 0. The value is 1.

[0036] When performing linear scaling on the water depth component The value is taken as the water depth component at the th Line 1 The original water depth values ​​for each grid cell. The value is taken as the minimum original water depth value of the water depth component in the whole watershed grid cell. The value is taken as the maximum original water depth value of the water depth component in the entire watershed grid cells. When performing linear scaling on the eastward velocity component... The value is taken as the eastward flow velocity component at the th Line 1 The original values ​​of the eastward flow velocity in the column grid cells. The value is taken as the minimum original value of the eastward velocity component in the entire watershed grid cell. The value is taken as the original value of the maximum eastward velocity component in the entire watershed grid cells. When performing linear scaling on the northward velocity component... The value is taken as the northward velocity component in the th order. Line 1 The original values ​​of the northward flow velocity in the column grid cells. The value is taken as the minimum original value of the northward velocity component in the entire watershed grid cell. The value is the original value of the maximum northward velocity component in the whole watershed grid cell.

[0037] For each rainfall grid in the hourly rainfall forcing field, a logarithmic transformation with the natural constant as the base is performed, followed by a linear scaling operation to map the numerical range of the hourly rainfall forcing field to a preset second numerical interval. The hourly rainfall forcing field contains a rainfall grid corresponding to each forecast time in multiple future forecast times. The rainfall grid records the hourly rainfall of each grid cell in the entire watershed at the corresponding time, in millimeters per hour.

[0038] In practice, the logarithmic transformation operation with the natural constant as the base is used to calculate the original rainfall value for each grid cell in the rainfall raster. implement Transformation, where This represents the rainfall value after logarithmic transformation. Represented by natural constant Logarithmic function with base 0. These are the smoothing coefficients for the logarithmic transformation. The value is 1.0. (Logarithmic transform smoothing coefficient) The value of 1.0 is based on the original rainfall value. When it is 0, This avoids the logarithmic function being undefined at zero, while ensuring the transformed values ​​remain non-negative. The transformed rainfall values... Then, a linear scaling operation is used to map the logarithmically transformed rainfall values ​​of each grid cell in the hourly rainfall forcing field to a preset second numerical interval. The preset second numerical interval is set to [0,1]. The formula for the linear scaling operation is the same as the formula described above, where... Replace with the first Line 1 Rainfall values ​​after logarithmic transformation of column grid cells , Replace with the minimum rainfall value among all grid cells after logarithmic transformation. Replace with the maximum rainfall value among all grid cells after logarithmic transformation. The value is 0. The value is 1.

[0039] For each raster data in the static underlying surface feature set, linear scaling or logarithmic transformation combined with linear scaling is performed according to the data type of each raster data to map the numerical range of each raster data to a preset third numerical interval. The preset third numerical interval is set to [0,1].

[0040] In some embodiments, raster data with continuous numerical values ​​and relatively uniform numerical distribution in the static underlying surface feature set are normalized using a linear scaling operation. The raster data with continuous numerical values ​​and relatively uniform numerical distribution includes digital elevation model data, leaf area index raster data, slope raster data, aspect sine component raster data, aspect cosine component raster data, and planar distance raster data. Linear scaling operations are performed on these raster data respectively, using the same formula as the linear scaling operation formula described above, with a preset third numerical interval... The value is 0. The value is 1.

[0041] In some embodiments, raster data in the static underlying surface feature set that are non-negative continuous values ​​with a range of variation spanning multiple orders of magnitude are normalized using a logarithmic transformation combined with linear scaling. Raster data that are non-negative continuous values ​​with a range of variation spanning multiple orders of magnitude includes runoff accumulation raster data and raster data with a height higher than the nearest drainage channel index. For these raster data, a logarithmic transformation with a base of the natural constant is first performed, and the logarithmic transformation smoothing coefficient is... All values ​​are set to 1.0, and then a linear scaling operation is performed to map the logarithmic transformation values ​​to a preset third numerical interval. The formula is the same as the logarithmic transformation combined with linear scaling operation used in hourly rainfall forcing operations, and the preset third numerical interval is... The value is 0. The value is 1.

[0042] In some embodiments, for raster data in the static underlying surface feature set that are ratio-type and whose numerical range is already within the [0,1] range, including land use type proportion raster data, soil sand content raster data, soil clay content raster data, soil organic matter content raster data, and river network mask raster data, the original values ​​are retained and no additional scaling operations are performed. The original values ​​of the land use type proportion raster data are decimals between 0 and 1, representing the area proportion of each land use type; the soil sand content raster data is represented as a mass fraction, and the original numerical range has been preprocessed and mapped to the [0,1] range; the soil clay content raster data is represented as a mass fraction, and the original numerical range has been preprocessed and mapped to the [0,1] range; the soil organic matter content raster data is represented as a mass fraction, and the original numerical range has been preprocessed and mapped to the [0,1] range; the first label value of the river network mask raster data is 1, and the second label value is 0.

[0043] After completing the dimensional normalization process, the hydrodynamic state field mapped to the first numerical interval, the hourly rainfall forcing field mapped to the second numerical interval, and the static underlying surface feature set mapped to the third numerical interval are uniformly mapped to the spatial resolution and grid alignment of the regular grid system through bilinear interpolation resampling operation, forming a multi-channel input tensor set.

[0044] In practical implementation, the bilinear interpolation resampling operation, for raster data requiring spatial resolution conversion, selects the values ​​of the four original grid cell centers closest to the center point coordinates of each grid cell in the regular grid system from the raster data to be resampled. A weighted average is then calculated based on the relative distances between the target coordinates and these four original grid cell coordinates to obtain the value of the corresponding grid cell in the regular grid system. After the bilinear interpolation resampling operation, the grid spatial resolution of the hydrodynamic state field, the hourly rainfall forcing field, and the static underlying surface feature set are all consistent with the preset spatial resolution of the regular grid system. To maintain consistency, all data is strictly aligned spatially.

[0045] The multi-channel input tensor set is formed by stacking the three components of the hydrodynamic state field (after dimensional normalization and bilinear interpolation resampling), the rainfall raster of all future forecast times for the hourly rainfall forcing field, and the thirteen channels of the static underlying surface feature set in a preset channel order along the channel dimension. The dimension format of the multi-channel input tensor set is [total number of channels, number of grid rows]. , the number of grid columns The total number of channels equals the number of channels in the hydrodynamic state field (3), the number of channels in the hourly rainfall forcing field equals the number of future forecast times, and the sum of the number of channels in the static underlying surface feature set (13).

[0046] In practical implementation, each grid cell in the regular grid system is used as the target center cell for spatial correlation measurement calculation. The spatial neighborhood of the target center cell is set to the grid cells covered by a 3×3 rectangular window centered on the target center cell. Excluding the target center cell itself, the spatial neighborhood includes eight neighboring grid cells. The basis for setting the spatial neighborhood is that the 3×3 rectangular window is consistent with the spatial range of the eight adjacent grid cells analyzed when calculating the water flow direction encoding in the D8 single-flow direction algorithm, which can capture the spatial dependency relationship between a grid cell and its immediate neighbors.

[0047] Extract the multi-channel feature vector of the target center cell from a multi-channel input tensor set. The multi-channel input tensor set has the dimension format [total number of channels, number of grid rows, number of grid columns]. For the target center cell located at row r and column c in the regular grid system, fix the row index r and column index c of the multi-channel input tensor set, and extract the values ​​of all channels along the channel dimension to form the multi-channel feature vector of the target center cell, denoted as . Multi-channel feature vectors The dimension is equal to the total number of channels in the multichannel input tensor set.

[0048] Extract multi-channel feature vectors from each neighboring grid cell within the spatial neighborhood of the target center cell in a multi-channel input tensor set. For the t-th neighboring grid cell within the spatial neighborhood, where t ranges from 1 to 8, set the row index of this neighboring grid cell in the regular grid system as... Column index is Row index of a fixed multi-channel input tensor set and column indexes The values ​​of all channels are extracted along the channel dimension to form the multi-channel feature vector of the neighborhood grid cell, denoted as . Multi-channel feature vectors The dimension is equal to the total number of channels in the multichannel input tensor set.

[0049] Calculate the multi-channel feature vector of the target central unit With the multi-channel feature vector of each neighboring grid cell The vector dot product between these elements yields eight original spatial correlation metrics. The vector dot product operation is performed by... and The scalar value obtained by multiplying the values ​​at the corresponding channel positions and summing them is the original spatial correlation metric for the t-th neighboring grid cell. The original spatial correlation metric reflects the similarity between the target center cell and the neighboring grid cell in the multi-channel feature space.

[0050] A flexible maximum normalization operation is performed on the eight original spatial correlation metrics to generate the correlation weight values ​​corresponding to the target center cell and each neighboring grid cell in the first correlation weight matrix. The flexible maximum normalization operation uses the Softmax function, and the calculation formula is as follows:

[0051] in, Indicates the target center unit and the first The association weight values ​​between neighboring grid cells The value of is an integer from 1 to 8; Indicates the target center unit and the first The original metric of spatial association between neighboring grid cells; Indicates the target center unit and the first The original metric of spatial association between neighboring grid cells For the summation index, The value of is an integer from 1 to 8; Represented by natural constant An exponential function with base 0.5. After flexible maximum normalization, the sum of the eight associated weight values ​​corresponding to the target central unit is 1, and each associated weight value... It is a real number between 0 and 1.

[0052] Using each grid cell in the regular grid system as the target center cell, the above-mentioned multi-channel feature vector extraction, vector inner product calculation, and flexible maximum normalization operation are repeatedly performed to generate eight associated weight values ​​corresponding to each grid cell. The set of associated weight values ​​corresponding to all grid cells in the regular grid system constitutes the first associated weight matrix. The size of the first associated weight matrix is ​​[number of grid rows, number of grid columns, 8], where the number of grid rows and the number of grid columns are the same as the number of grid rows in the regular grid system. and the number of grid columns Consistent, the first association weight matrix stores a weight vector of length 8 at each grid cell position. This weight vector records the association weight values ​​between the grid cell and eight neighboring grid cells within the spatial neighborhood in a fixed neighborhood order.

[0053] In specific implementation, please refer to Figure 3Spatial distribution redistribution is performed using each grid cell in the regular grid system as the target weighted cell. For a target weighted cell located in row g and column h of the regular grid system, the multi-channel feature vectors of the eight neighboring grid cells corresponding to the target weighted cell are extracted according to the first correlation weight matrix. The size of the first correlation weight matrix is ​​[number of grid rows, number of grid columns, 8]. In the first correlation weight matrix, a weight vector of length 8 is stored at row g and column h, and each weight value in the weight vector corresponds to a neighboring grid cell. According to the neighboring grid cell index indicated by the weight vector stored in row g and column h of the first correlation weight matrix, the corresponding eight neighboring grid cells are retrieved in the multi-channel input tensor set. For the kth neighboring grid cell among the eight neighboring grid cells, k is an integer from 1 to 8, and the row index of the kth neighboring grid cell in the regular grid system is... The column index is Row indices of a fixed-channel input tensor set and column indexes The values ​​of all channels are extracted along the channel dimension to form the multi-channel feature vector of the k-th neighborhood grid cell, denoted as . Multi-channel feature vectors The dimension is equal to the total number of channels in the multichannel input tensor set.

[0054] After extracting the multi-channel feature vectors of the eight neighboring grid cells corresponding to the target weighted cell, the multi-channel feature vectors of the eight neighboring grid cells are multiplied element-wise with the eight associated weight values ​​corresponding to the target weighted cell in the first associated weight matrix. The associated weight value corresponding to the k-th neighboring grid cell in the eight associated weight values ​​stored in the g-th row and h-th column of the first associated weight matrix is ​​denoted as... Element-wise multiplication refers to multiplying the multi-channel feature vector of the k-th neighboring grid cell. The value of each channel is multiplied by the associated weight value. This yields the k-th weighted eigenvector. The calculation formula is:

[0055] in, This represents the k-th weighted feature vector corresponding to the target weighted unit. The value of is an integer from 1 to 8; In a regular grid system, the first Line 1 Column target weighted unit and the first The association weight values ​​between neighboring grid cells It is extracted directly from the first correlation weight matrix. It is a real number, and its value ranges from 0 to 1; Indicates the first Multi-channel feature vectors of neighborhood grid cells; This represents the element-wise multiplication operator, which indicates the association of weight values. With multi-channel feature vectors The values ​​at each channel position are multiplied together, and the result forms a weighted eigenvector. The numerical value corresponding to the channel position. Weighted feature vector. Dimensionality and multi-channel feature vectors The dimension is the same, which is equal to the total number of channels in the multi-channel input tensor set.

[0056] Repeating the element-wise multiplication operation above, the eight neighboring grid cells corresponding to the target weighted cell generate eight weighted feature vectors, which are respectively , until .

[0057] An element-wise summation operation is performed on the eight weighted feature vectors to obtain the aggregated feature vector of the target weighted unit. The element-wise summation operation involves accumulating the values ​​corresponding to the same channel position in the eight weighted feature vectors, and the sum is used as the value of the aggregated feature vector at that channel position. The dimension of the aggregated feature vector is the same as that of the weighted feature vectors, equal to the total number of channels in the multi-channel input tensor set. The aggregated feature vector is used as the watershed state-space mapping value of the target weighted unit. The watershed state-space mapping value is a multi-channel vector representation that encodes the spatial context information formed by the target weighted unit after integrating its own multi-channel features and those of its spatially neighboring grid units.

[0058] Using each grid cell in the regular grid system as the target weighting cell, the aforementioned operations of extracting multi-channel feature vectors from neighboring grid cells, performing element-wise multiplication, and summing are repeatedly executed to generate a corresponding aggregated feature vector for each grid cell in the regular grid system. The aggregated feature vectors of all grid cells, arranged spatially according to the regular grid system, constitute the watershed state space mapping value corresponding to the current forecast time. The spatial dimension of the watershed state space mapping value is consistent with the number of grid rows and columns in the regular grid system, and the channel dimension is consistent with the total number of channels in the multi-channel input tensor set.

[0059] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A smart flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture, characterized in that, The system acquires the set of static underlying surface features of the target watershed, the hydrodynamic state field at the time of forecast, and the hourly rainfall forcing field at multiple future forecast times. Based on the digital elevation data in the static underlying surface feature set, a regular grid system for the target watershed is constructed, and for each grid cell in the regular grid system, a flow direction index code and a confluence path topology relationship are established. After the hydrodynamic state field, the hourly rainfall forcing field and the static underlying surface feature set are respectively subjected to dimensional normalization, they are uniformly mapped to the regular grid system to form a spatially aligned multi-channel input tensor set. Perform a spatial correlation metric operation based on grid cells on the multi-channel input tensor set to generate a first correlation weight matrix that characterizes the degree of spatial dependence between grid cells in the regular grid system. Based on the first correlation weight matrix, the spatial distribution of the multi-channel input tensor set on the regular grid system is redistributed to obtain the watershed state space mapping value corresponding to the current forecast time.

2. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 1, characterized in that, The step of constructing a regular grid system for the target watershed based on the digital elevation data in the static underlying surface feature set, and establishing flow direction index encoding and confluence path topology for each grid cell in the regular grid system, includes: Using the preset center point coordinates of the target watershed as a reference point, and according to the preset spatial resolution and number of grid rows and columns, a rectangular grid frame covering the target watershed is generated as the regular grid system; Traverse each grid cell in the regular grid system, determine the water flow direction code of the grid cell based on the elevation value of the grid cell in the digital elevation data and the elevation values ​​of its eight neighboring grid cells, and use the water flow direction code as the flow direction index code of the grid cell. Based on the flow direction index encoding of each grid cell, a stack scan algorithm is used to trace the path of each grid cell to the preset river channel grid cell along the water flow direction, forming the topological relationship of the confluence path of each grid cell.

3. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 2, characterized in that, The step of obtaining the static underlying surface feature set of the target watershed includes: Obtain digital elevation model data, leaf area index raster data, land use type ratio raster data, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data for the target watershed; Based on the digital elevation model data, calculate the slope raster data, the sine component raster data, the cosine component raster data, the runoff accumulation raster data, and the index data of height above the nearest drainage channel. Based on the digital elevation model data, extract the river network mask grid data of the target watershed, and calculate the planar distance grid data from each grid cell to the nearest river channel grid cell in the regular grid system. The digital elevation model data, leaf area index raster data, land use type proportion raster data, soil sand content raster data, soil clay content raster data, soil organic matter content raster data, slope raster data, aspect sine component raster data, aspect cosine component raster data, runoff accumulation raster data, height above nearest drainage channel index raster data, river network mask raster data, and planar distance raster data are combined by channel to form the static underlying surface feature set.

4. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 1, characterized in that, The step of uniformly mapping the hydrodynamic state field, the hourly rainfall forcing field, and the static underlying surface feature set to the regular grid system after dimensional normalization to form a spatially aligned multi-channel input tensor set includes: For the water depth component, eastward flow velocity component, and northward flow velocity component in the hydrodynamic state field, a linear scaling operation is performed to map the numerical range of each component to a preset first numerical interval. For each rainfall grid in the hourly rainfall forcing field, a logarithmic transformation operation with the natural constant as the base is performed, and then a linear scaling operation is used to map the numerical range of the rainfall grid to a preset second numerical interval. For each grid data in the static underlying surface feature set, linear scaling operation or logarithmic transformation combined with linear scaling operation is performed according to the data type of each grid data to map the numerical range of each grid data to a preset third numerical interval. The hydrodynamic state field mapped to the first numerical interval, the hourly rainfall forcing field mapped to the second numerical interval, and the static underlying surface feature set mapped to the third numerical interval are uniformly mapped to the spatial resolution and grid alignment of the regular grid system through bilinear interpolation resampling operation to form the multi-channel input tensor set.

5. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 1, characterized in that, The step of performing a spatial correlation metric operation based on grid cells on the multi-channel input tensor set to generate a first correlation weight matrix characterizing the spatial dependence between grid cells in the regular grid system includes: Using each grid cell in the regular grid system as the target center cell, the multi-channel feature vector of the target center cell is extracted from the multi-channel input tensor set, and the multi-channel feature vectors of each neighboring grid cell within the spatial neighborhood of the target center cell are also extracted. Calculate the vector inner product between the multi-channel feature vector of the target center unit and the multi-channel feature vector of each of the neighboring grid units to obtain multiple spatial correlation original metric values; A flexible maximum value normalization operation is performed on the multiple spatial correlation original metric values ​​to generate the correlation weight values ​​in the first correlation weight matrix corresponding to the correlation weight values ​​between the target center unit and each of the neighboring grid units.

6. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 5, characterized in that, The step of redistributing the spatial distribution of the multi-channel input tensor set on the regular grid system according to the first correlation weight matrix to obtain the watershed state space mapping value corresponding to the current forecast time includes: Using each grid cell in the regular grid system as the target weighting cell, and based on the first association weight matrix, extract the multi-channel feature vectors of multiple neighboring grid cells corresponding to the target weighting cell; The multi-channel feature vectors of the multiple neighborhood grid cells are multiplied element-wise with the corresponding association weight values ​​in the first association weight matrix to obtain multiple weighted feature vectors. An element-wise summation operation is performed on the multiple weighted feature vectors to obtain the aggregated feature vector of the target weighted unit, and the aggregated feature vector is used as the watershed state space mapping value of the grid unit.

7. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 2, characterized in that, The water flow direction encoding adopts the D8 single flow direction algorithm, which determines the water flow direction encoding of the grid cell based on the maximum elevation gradient between the central grid cell and the eight adjacent grid cells.

8. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 2, characterized in that, The stack scanning algorithm is a depth-first search algorithm. It uses the flow direction index encoding of each grid cell as the edge and recursively traces along the water flow direction to the preset river grid cell to form the topological relationship of the confluence path of each grid cell.

9. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 3, characterized in that, The digital elevation model data, leaf area index raster data, land use type ratio raster data, soil sand content raster data, soil clay content raster data, and soil organic matter content raster data are all derived from satellite remote sensing inversion products with a preset spatial resolution.

10. The intelligent flood forecasting method for small and medium-sized watersheds based on the Transformer-Unet architecture according to claim 4, characterized in that, The linear scaling operation uses a minimum-maximum normalization formula, which subtracts the minimum value of each element in the data to be normalized from the data range and then divides the result by the range of the data to achieve numerical range mapping.