A method and system for extracting inland lake basins based on digital elevation model
Patent Information
- Application Number
- CN202210992072.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-08-17
AI Technical Summary
The prior art is difficult to effectively extract the basin boundaries of inland lakes, resulting in a high error rate and is not suitable for intravenous water bodies.
Using a method based on the digital elevation model, the initial raster flow direction is calculated, the depression cell collection is identified, and land depressions and lake depressions are identified based on the lake distribution data, and selective filling is carried out to construct multi-fork trees in the flow direction, and the lake basin boundary is extracted using the tree-like data structure traversal algorithm.
The boundaries of inland lake basin are extracted with high efficiency and accuracy, reflecting the true hydrological information of inland lake basin, and reducing the possibility of human error.
Smart Images

Figure CN115359221B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of geographic information analysis, and more specifically, to a method and system for extracting inland lake basins based on a digital elevation model. Background Art
[0002] Inland lakes refer to relatively static water bodies in inland depressions with a certain area and no direct connection with the ocean. Some inland lakes have no rivers flowing out, while some inland lakes have rivers flowing out to the next lake or disappearing inland. Studying the watershed boundaries of inland lakes is of great significance for understanding the distribution characteristics of water resources in inland basins and the impact of lakes on climate change and agricultural production. However, the widely used hydrological information extraction program based on digital elevation models is applicable to outflow basins that are hydraulically connected to the ocean, but not to inland water bodies such as inland lakes, which require special terrain processing steps. In actual work, the watershed boundaries of inland lakes are usually determined by artificially drawing ridge lines, which is prone to errors when there are too many lakes. Summary of the invention
[0003] In order to overcome the defects of the above-mentioned prior art in lacking a method for extracting hydrological information of inland lakes and a high error rate when determining the watershed boundaries of inland lakes, the present invention provides a method and system for extracting inland lake watersheds based on a digital elevation model.
[0004] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0005] A method for extracting inland lake basins based on a digital elevation model comprises the following steps:
[0006] S1. Input the digital elevation model and lake distribution data of the target area;
[0007] S2, calculating the initial grid flow direction of each pixel in the digital elevation model of the target area, and selecting pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set;
[0008] S3, identifying the land depressions and lake depressions in the depression pixel combination according to the lake distribution data, and obtaining a land depression pixel set and a lake depression pixel set;
[0009] S4, selectively filling corresponding land depression pixels in the digital elevation model, and then calculating the grid flow direction to obtain a grid flow direction matrix;
[0010] S5, parsing the grid flow direction matrix and constructing a flow direction multi-branch tree;
[0011] S6. Iteratively traverse the lake distribution data to extract edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixels as the starting pixels to perform subtree layer traversal using the flow multi-branch tree to extract the lake basin boundary.
[0012] This technical solution is aimed at terrain processing and lake watershed extraction in inland basins. It analyzes and fills depression pixels according to the terrain characteristics of inland basins, analyzes the raster flow direction and constructs a multi-branch flow tree. The tree data structure traversal algorithm is applied to lake watershed extraction to achieve the extraction of watershed boundaries of inland water bodies such as inland lakes.
[0013] Furthermore, the present invention also proposes an inland lake basin extraction system based on a digital elevation model, which applies the inland lake basin extraction method proposed in the above technical solution, including a data acquisition module, a depression identification module, a depression filling module, a flow multi-branch tree construction module, and a lake basin boundary extraction module.
[0014] Among them, the data acquisition module is used to obtain the digital elevation model and lake distribution data of the target area;
[0015] The depression identification module is used to calculate the initial grid flow direction of each pixel in the digital elevation model of the target area, and select pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set; and is used to identify the land surface depressions and lake depressions in the depression pixel combination according to the lake distribution data, and output the land surface depression pixel set and the lake depression pixel set;
[0016] The depression filling module is used to selectively fill the corresponding land depression pixels in the digital elevation model, and then calculate the grid flow direction and output the grid flow direction matrix;
[0017] A flow direction multi-branch tree construction module, used for parsing the grid flow direction matrix and constructing a flow direction multi-branch tree;
[0018] The lake basin boundary extraction module is used to iteratively traverse the lake distribution data, extract the edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixels as the starting pixels to perform subtree layer traversal using the flow multi-branch tree to output the extracted lake basin boundary data.
[0019] Furthermore, the present invention also proposes an inland lake basin extraction system based on a digital elevation model, comprising a memory and a processor, wherein the memory stores a computer program, wherein the processor implements the steps of the inland lake basin extraction method proposed in the present invention when executing the computer program.
[0020] Compared with the prior art, the beneficial effects of the technical solution of the present invention are as follows: the present invention processes and analyzes the digital elevation model and lake distribution data of the target area by combining the topographic features of inland water bodies such as inland lakes, judges whether the pixel in the digital elevation model is an inland lake according to the grid flow direction of each pixel, and selectively fills the depression pixels, effectively reflecting the real hydrological information of the inland lake basin, and further constructs a flow direction multi-branch tree, applies the tree data structure traversal algorithm to lake basin extraction, and realizes efficient and high-accuracy basin boundary extraction of inland water bodies such as inland lakes. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flow chart of the inland lake basin extraction method based on the digital elevation model of Example 1 of the present invention.
[0022] Figure 2 This is the digital elevation model of the Qiangtang Plateau and the lake distribution characteristic map of Example 2 of the present invention.
[0023] Figure 3 This is a schematic diagram of the distribution of depressions in the Qiangtang Plateau area according to Example 2 of the present invention.
[0024] Figure 4 This is a schematic diagram of the distribution of lake depressions in the Qiangtang Plateau area of Example 2 of the present invention.
[0025] Figure 5 Schematic diagram of the land surface depression filling principle of Example 2 of the present invention.
[0026] Figure 6 This is a schematic diagram of the lake basin boundary in the Qiangtang Plateau area of Example 2 of the present invention.
[0027] Figure 7 This is an architectural diagram of the inland lake basin extraction system of Example 3 of the present invention. DETAILED DESCRIPTION
[0028] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;
[0029] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0030] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0031] Example 1
[0032] In order to solve the problem that the inland basin area has complex terrain and depressions in watershed management, and the lake basin boundary cannot be extracted using conventional hydrological processing programs, this embodiment proposes an inland lake basin extraction method based on a digital elevation model.
[0033] See also Figure 1 The steps of the inland lake basin extraction method proposed in this embodiment are as follows:
[0034] S1. Input the digital elevation model and lake distribution data of the target area.
[0035] S2. Calculate the initial grid flow direction of each pixel in the digital elevation model of the target area, and select pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set.
[0036] S3. Identify the land surface depressions and lake depressions in the depression pixel combination according to the lake distribution data, and obtain a land surface depression pixel set and a lake depression pixel set.
[0037] S4. Selectively fill the corresponding land surface depression pixels in the digital elevation model, and then calculate the grid flow direction to obtain a grid flow direction matrix.
[0038] S5. Analyze the grid flow direction matrix and construct a flow direction multi-branch tree.
[0039] S6. Iteratively traverse the lake distribution data to extract edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixels as the starting pixels to perform subtree layer traversal using the flow multi-branch tree to extract the lake basin boundary.
[0040] In this embodiment, the initial grid flow direction is first calculated, and a set of depression pixels whose flow direction cannot be determined is extracted from the raster flow direction. Then, the lake distribution data is converted into a mask array to identify and distinguish the land depressions and lake depressions in the depression set, so as to facilitate the subsequent depression processing steps. After identifying the depressions belonging to the lakes in the digital elevation model, the land depressions can be selectively filled, and the lake depressions can be retained. Then, the raster flow direction data is calculated, and a flow multi-branch tree is constructed for the subsequent lake basin extraction steps. Finally, the lake data set is iteratively traversed to extract the outer boundary line of the lake vector, and then the lake edge pixel is used as the starting pixel, and the flow multi-branch tree is used to perform a subtree layer traversal to extract the lake basin boundary.
[0041] In an optional embodiment, the step of calculating the initial grid flow direction of each pixel in the digital elevation model of the target area in step S2 includes:
[0042] S2.1. Calculate the elevation difference between each pixel in the digital elevation model of the target area and the surrounding eight pixels.
[0043] S2.2. Divide the elevation difference between each pixel and its adjacent pixel by the distance between the pixels to calculate the slope between the pixels.
[0044] S2.3. According to the slope between each pixel, set the direction along the maximum slope as the initial grid flow direction.
[0045] In this embodiment, the grid flow direction is obtained based on the assumption that water flows in the direction with the largest slope.
[0046] Furthermore, according to the initial grid flow direction of each pixel, for the depression pixel in the digital elevation model, its elevation is lower than the surrounding pixels, and the elevation differences in the eight directions are all negative. Water cannot flow from this pixel to other pixels, and its flow direction is to be determined.
[0047] Therefore, the step of selecting pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set includes:
[0048] Traverse each pixel in the digital elevation model and make judgments:
[0049] If the elevation value of the current pixel is lower than that of the surrounding 8 pixels, or the elevation difference between the current pixel and the surrounding 8 pixels is negative, the current pixel is judged as a pixel whose flow direction cannot be determined, the current pixel is added to the depression pixel set, and the current pixel is filled with the preset depression pixel filling value.
[0050] In a specific implementation process, positive integers 1, 2, 3, 4, 5, 6, 7, and 8 are used to represent eight flow directions, namely east, northeast, north, northwest, west, southwest, south, and southeast. For depression pixels, the flow direction is to be determined and is represented by a fill value of -32768.
[0051] Among them, the grid flow direction data is used to assist in depression identification and does not participate in the subsequent inland lake basin extraction.
[0052] In an optional embodiment, the step of identifying the land surface depressions and lake depressions in the depression pixel combination according to the lake distribution data in step S3 includes:
[0053] S3.1. Extract corresponding pixel numbers according to the depression pixel set to form a depression pixel number set sink total ; Its expression is as follows:
[0054] sink total ={pixel i,j |flowdir i,j =fillvalue}
[0055] pixel i,j =i*rows+j
[0056]
[0057] In the formula, pixel i,jIndicates the pixel number of the i-th row and j-th column, flowdir i,j Indicates the flow direction of the pixel in the i-th row and j-th column. fillvalue is the preset depression pixel filling value. rows is the number of rows of the digital elevation model, and cols is the number of columns of the digital elevation model.
[0058] In this step, the pixels whose flow directions are filled values are regarded as depression pixels, and a set of depression pixel numbers is obtained.
[0059] S3.2. According to the lake distribution data, the kth lake is converted from a vector to a raster with the same shape and resolution as the original digital elevation model, where the pixels covered by the lake are 1 and the pixels not covered by the lake are 0, and the mask matrix mask of the kth lake is obtained. lake,k .
[0060] S3.3, sink from the depression pixel number set total Extract the depressions covered by lakes, and after traversing all lake distribution data, obtain the lake depression pixel set and the land depression pixel set; its expression is as follows:
[0061]
[0062] In the formula, sink lake,k represents the set of depression pixels covered by the kth lake, where sink lake,k A value of 0 indicates that the pixel belongs to a land depression pixel. lake,k A value of 1 indicates that the pixel belongs to a lake depression pixel; sink t Represents the sink pixel number set total The tth pixel in ;
[0063] Finally, according to the sink lake,k The values of are divided into a set of land depression pixels and a set of lake depression pixels.
[0064] In this embodiment, by extracting the number set of depression pixels, it is convenient to judge whether each depression belongs to a lake depression or a land depression and process them separately.
[0065] In addition, considering that in the depression pixel set, some depressions are generated by digital elevation model photography imaging, data filtering processing and other processes, and do not represent the real terrain; some depressions reflect the real terrain and need to be retained in the digital elevation model processing program. Steps S3.2 and S3.3 of this embodiment are used to identify land depressions and lake depressions. The lake mask matrix converted from the lake distribution data is covered on the pixel, and the depression pixel number covered by the lake is extracted from the depression pixel number set. The covered depression pixel number is the lake pixel number.
[0066] The water level of inland lakes changes with the seasons. Some depressions are covered by lakes in wet years, but will be exposed outside the lakes and become land depressions in normal or dry years. Therefore, it is necessary to identify the lowest depression among the lake depressions, and the rest are regarded as land depressions. This treatment does not affect the extraction of lake basins.
[0067] Therefore, further, step S3 of this embodiment also includes the following steps:
[0068] After identifying the set of depression pixels covered by the kth lake, the elevation of each pixel is queried through the digital elevation model, and the pixel with the smallest elevation value is retained; its expression is as follows:
[0069]
[0070] sink 1 ,sink 2 ,...,sink n ∈sink lake,k
[0071] In the formula, sink' represents the lowest depression covered by the kth lake, Indicates sink t The corresponding elevation.
[0072] After repeating the above operation for all lakes, we get the lowest sink of all lakes. lowest , and then obtain the land surface depression set sink through difference calculation land =sink total --sink lowest .
[0073] Further, in an optional embodiment, the specific steps of step S4 include:
[0074] S4.1. Convert the lake depression pixel set into a mask array with the same shape and resolution as the original digital elevation model. sink ; Mask array mask sink In the image, the pixels belonging to lake depressions are marked as 1, and the pixels not belonging to lake depressions are marked as 0.
[0075] S4.2, according to the mask array mask sink , fill and remove the depressions marked as 0.
[0076] S4.3, after filling the mask array mask sink Perform flow direction calculation and obtain the grid flow direction matrix fdir in the digital elevation model.
[0077] In this step, after identifying the depressions belonging to lakes in the digital elevation model, the land depressions are selectively filled, the lake depressions are retained, and then the raster flow direction data is calculated for the subsequent lake basin extraction step.
[0078] First, the set of lake depression pixel numbers is converted into a mask array with the same shape and resolution as the original digital elevation model. sink , the mask array marks the depressions that need to be retained, and the depressions not marked by the array will be filled and removed.
[0079] In a specific implementation process, the pitremove function in the TauDEM program is used to convert the mask array mask sink Pass in the depmask parameter to mask the unmasked array sink The marked depressions are filled and removed.
[0080] When calculating the flow direction, the TauDEM program fills all depressions by default. When eliminating the influence of pseudo-depressions, the real depressions will also be removed, which cannot reflect the real hydrological information of inland lake basins. The depmask parameter can mark the real depressions in the digital elevation model. The marked depressions will not be filled, and the flow direction of the basin pixels corresponding to the marked depressions can still point to the depressions.
[0081] Therefore, in a specific implementation process, the grid flow direction matrix fdir is calculated by calling the flowdir flow direction calculation program in the TauDEM program.
[0082] Further, in an optional embodiment, the specific steps in step S5 include:
[0083] S5.1. Analyze the grid flow matrix fdir to construct the corresponding relationship between the upstream pixels and the downstream pixels; the expression is as follows:
[0084] dir(pixel i,j )=pixel i,j +offset(fdir(i,j))
[0085] pixel i,j =i*rows+j
[0086]
[0087] In the formula, pixel i,jrepresents the pixel number of the i-th row and j-th column, rows is the number of rows of the digital elevation model, and cols is the number of columns of the digital elevation model; fdir(i,j) represents the grid flow direction of the pixel of the i-th row and j-th column, offset(·) represents the number offset between the upstream pixel and the downstream pixel, and dir(·) represents the correspondence between the upstream pixel and the downstream pixel.
[0088] S5.2. Analyze the grid flow matrix fdir, construct the relationship between the downstream pixels and the upstream pixels, and save it as a dictionary; its expression is as follows:
[0089] dir inverse (pixel i,j )={pixel m,n |dir(pixel m,n )=pixel i,j}
[0090]
[0091]
[0092] In the formula, dir inverse (·) indicates the correspondence between downstream pixels and upstream pixels, pixel m,n Indicates that the downstream pixel is pixel i,j The upstream pixel of this condition.
[0093] S5.3. According to the correspondence between the upstream pixels and the downstream pixels, and the relationship between the downstream pixels and the upstream pixels, a multi-branch tree of flow directions is constructed.
[0094] In this embodiment, for 8 different flow directions, the expression of the number offset relationship between the upstream pixel and the downstream pixel is as follows:
[0095]
[0096] Where offset(·) represents the number offset between the upstream pixel and the downstream pixel, y represents the grid flow direction of the upstream pixel, and 1, 2, 3, 4, 5, 6, 7, and 8 represent the eight flow directions of east, northeast, north, northwest, west, southwest, south, and southeast, respectively.
[0097] One upstream pixel corresponds to only one downstream pixel, but one downstream pixel corresponds to multiple upstream pixels. The process of extracting the watershed lake in this embodiment is to iteratively search from downstream to upstream according to the raster flow direction. It is necessary to parse the corresponding relationship dir between the upstream pixel and the downstream pixel, and construct the relationship between the downstream pixel and the upstream pixel. Finally, the flow multi-branch tree is saved in the form of a dictionary for subsequent lake basin extraction.
[0098] Further, in an optional embodiment, the specific steps in step S6 include:
[0099] S6.1. Iterate the lake distribution data to extract the outer boundary line of the lake vector, and convert the outer boundary line from vector data to raster data to extract the edge pixels corresponding to the lake.
[0100] S6.2. Take the edge pixel corresponding to the lake as the starting pixel and use the flow multi-branch tree to perform subtree layer traversal; wherein, after querying the upstream pixel of the starting pixel, take the current upstream pixel as the starting pixel again, and extract iteratively back and forth to obtain the lake basin boundary.
[0101] In a specific implementation process, the lake dataset is iterated, and the exterior method in the third-party Python library shapely is called to extract the outer boundary line of the lake vector. The geometry_mask method in the third-party library rasterio is used to convert the boundary line from vector data to raster data to extract the edge pixels corresponding to the lake. The lake edge pixels are used as the starting pixels, and the flow multi-branch tree is used to perform subtree hierarchical traversal. After querying the upstream pixels of the starting pixels, the upstream pixels are used again as the starting pixels, and the lake basin boundaries are extracted iteratively.
[0102] In this embodiment, by combining the topographic features of inland water bodies such as inland lakes, the digital elevation model and lake distribution data of the target area are processed and analyzed, and based on the raster flow direction of each pixel, it is judged whether the pixel in the digital elevation model is an inland lake, and the depression pixels are selectively filled, which effectively reflects the true hydrological information of the inland lake basin, and is further used to construct a flow direction multi-branch tree, and the tree data structure traversal algorithm is applied to lake basin extraction, thereby achieving efficient and high-accuracy basin boundary extraction of inland water bodies such as inland lakes.
[0103] Example 2
[0104] See also Figure 2 to Figure 6 This embodiment applies the inland lake basin extraction method proposed in Example 1 to extract the inland lake basin in the Qiangtang Plateau.
[0105] Step 1: This embodiment stores the digital elevation model and lake location data required for the extraction of the lake basin in the Qiangtang Plateau in the same folder, and then defines the variables dem and lake to store the file paths of the two original data, and calculates the initial flow direction through the d8flowdir function in pygeoc.
[0106] Step 2: Use the where function in numpy to identify the depressions in the Qiangtang Plateau area and obtain the following Figure 2The digital elevation model of the Qiangtang Plateau and the distribution characteristics of lakes are shown in Figure 2. Figure 3 As shown in the figure, the depth of the grayscale color represents the depth of the depression. It can be seen that some of the depressions are covered by lakes, but most of the depressions are still land depressions.
[0107] Step 3: Distinguish the depressions in the Qiangtang Plateau and identify the lake depressions and land depressions. Use the geometry_mask function in rasterio to convert the lake vector location data into raster data, and perform overlay analysis with the depressions identified in step 2. For the depressions covered by each lake, only the depression with the lowest elevation is retained as the lake depression, and the other depressions are regarded as land depressions. The following is obtained: Figure 4 Map showing the distribution of lake depressions, where the dot pattern represents the lowest depressions covered by lakes.
[0108] Step 4: Use the Pitremove function in the TauDEM program to fill the land depressions and retain the lake depressions. The schematic diagram of this method is shown in the figure. Figure 5 As shown, the inverted triangle represents the lowest point of the depression, and the arrow represents the direction of water flow. Figure 5 The left picture (a) is a schematic diagram of the depression before treatment. Figure 5 The right figure (b) is a schematic diagram of the processed depression, in which the land depression is filled to the same height as the depression edge, while the lake depression is retained.
[0109] Step 5: Use the flowdir function in the TauDEM program to calculate the raster flow direction of the processed digital elevation model of the Qiangtang Plateau, and then parse the flow direction data according to the offset relationship between the upstream pixel and downstream pixel numbers of different flow directions, and use the dict data type in Python to save the mapping relationship between the upstream pixels and the downstream pixels.
[0110] Step 6: Analyze the mapping relationship between the upstream pixels and the downstream pixels in step 5, use the tuple data type in Python to save the upstream pixels of each downstream pixel, establish the mapping relationship between the downstream pixels and the upstream pixels, and construct the flow multi-branch tree.
[0111] Step 7: Use the for loop in Python to traverse the lake dataset. For any lake, use the exterior method in shapely to extract the lake boundary, then convert the lake boundary into raster pixels, use the flow multitree to traverse these edge pixels, extract the lake basin boundary, and obtain the Polygon object in shapely. Use the to_file method in geopandas to save the lake basins. The final schematic diagram of the lake basin boundary in the Qiangtang Plateau is as follows: Figure 6 shown.
[0112] Example 3
[0113] This embodiment proposes an inland lake basin extraction system based on a digital elevation model, and applies the inland lake basin extraction method proposed in Example 1. Figure 7 , is the architecture diagram of the inland lake basin extraction system of this embodiment.
[0114] The inland lake watershed extraction system proposed in this embodiment includes a data acquisition module, a depression identification module, a depression filling module, a flow multi-branch tree construction module, and a lake watershed boundary extraction module.
[0115] in:
[0116] The data acquisition module is used to obtain the digital elevation model and lake distribution data of the target area.
[0117] The depression identification module is used to calculate the initial grid flow direction of each pixel in the digital elevation model of the target area, and select pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set; and is used to identify the land depressions and lake depressions in the depression pixel combination according to the lake distribution data, and output the land depression pixel set and the lake depression pixel set.
[0118] The depression filling module is used to selectively fill the corresponding land depression pixels in the digital elevation model, then calculate the grid flow direction, and output the grid flow direction matrix.
[0119] The flow direction multi-branch tree construction module is used to parse the grid flow direction matrix and construct a flow direction multi-branch tree.
[0120] The lake basin boundary extraction module is used to iteratively traverse the lake distribution data, extract the edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixels as the starting pixels to perform subtree layer traversal using the flow multi-branch tree to output the extracted lake basin boundary data.
[0121] In a specific implementation process, the data acquisition module transmits the acquired digital elevation model and lake distribution data of the target area to the depression identification module for depression identification processing.
[0122] The depression identification module calculates the elevation difference between each pixel in the digital elevation model of the target area and the surrounding 8 pixels based on the input digital elevation model data, divides the elevation difference between each pixel and the adjacent pixel by the distance between the pixels, calculates the slope between the pixels, and sets the direction with the maximum slope as the initial grid flow direction based on the slope between the pixels. Then, based on the initial grid flow direction, traverse each pixel in the digital elevation model and make a judgment: if the elevation value of the current pixel is lower than the surrounding 8 pixels, or the elevation difference between the current pixel and the surrounding 8 pixels is negative, the current pixel is judged as a pixel whose flow direction cannot be determined, the current pixel is added to the depression pixel set, and the current pixel is filled with the preset depression pixel filling value.
[0123] Furthermore, the depression identification module extracts the corresponding pixel numbers according to the depression pixel set to form a depression pixel number set, and according to the lake distribution data, converts the k-th lake from a vector into a raster with the same shape and resolution as the original digital elevation model, where the pixels covered by the lake are 1 and the pixels not covered by the lake are 0, thereby obtaining a mask matrix mask of the k-th lake. lake,k ; Finally, sink from the depression pixel number set total The depressions covered by lakes are extracted from the dataset, and after traversing all lake distribution data, a lake depression pixel set and a land depression pixel set are obtained. The depression identification module sends the lake depression pixel set and the land depression pixel set to the depression filling module.
[0124] The depression filling module converts the lake depression pixel set into a mask array with the same shape and resolution as the original digital elevation model. sink ; Mask array mask sink In the example, the pixels belonging to the lake depression are marked as 1, and the pixels not belonging to the lake depression are marked as 0, and then the mask array mask is used. sink , fill and remove the depressions marked as 0, and then perform masking on the filled mask array mask sink Calculate the flow direction and get the grid flow direction matrix fdir in the digital elevation model. The depression filling module sends the grid flow direction matrix fdir generated by its calculation to the flow multi-branch tree construction module.
[0125] The flow direction multi-branch tree construction module parses the input grid flow direction matrix fdir, constructs the correspondence between the upstream pixels and the downstream pixels, and parses the grid flow direction matrix fdir, constructs the relationship between the downstream pixels and the upstream pixels, and finally constructs the flow direction multi-branch tree according to the correspondence between the upstream pixels and the downstream pixels, and the relationship between the downstream pixels and the upstream pixels. The flow direction multi-branch tree construction module sends the generated flow direction multi-branch tree to the lake basin boundary extraction module.
[0126] The lake basin boundary extraction module iteratively traverses the lake distribution data, extracts the outer boundary line of the lake vector, and converts the outer boundary line from vector data to raster data to extract the edge pixels corresponding to the lake, and then uses the edge pixels corresponding to the lake as the starting pixels, and uses the flow multi-branch tree to perform subtree layer traversal; wherein, after querying the upstream pixel of the starting pixel, the current upstream pixel is again used as the starting pixel, and the extraction is iteratively repeated to obtain the lake basin boundary and output it.
[0127] Furthermore, this embodiment also proposes an inland lake basin extraction system based on a digital elevation model, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the inland lake basin extraction method proposed in Example 1 when executing the computer program.
[0128] Specifically, by defining the class class and the function def(), the depression terrain processing and lake basin extraction process in steps S1 to S6 are encapsulated into multiple classes and functions, and the code is saved as a .py format file. When it is needed, the class and function can be imported using the import function and used.
[0129] The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent;
[0130] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for extracting inland lake basins based on digital elevation models, It is characterized in that The following steps are involved: S1. Input the digital elevation model and lake distribution data of the target area; S2, calculating the initial grid flow direction of each pixel in the digital elevation model of the target area, and selecting pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set; S3, identifying the land surface depressions and lake depressions in the depression pixel set according to the lake distribution data, and obtaining a land surface depression pixel set and a lake depression pixel set; S4, selectively filling corresponding land depression pixels in the digital elevation model, and then calculating the grid flow direction to obtain a grid flow direction matrix; S5, parsing the grid flow matrix and constructing a flow multi-branch tree; the specific steps include: S5.
1. Analyze the grid flow matrix fdir to construct the corresponding relationship between the upstream pixels and the downstream pixels; the expression is as follows: dir(pixel i,j )=pixel i,j +offset(fdir(i,j)) pixel i,j =i*rows+j In the formula, pixel i,j represents the pixel number of the i-th row and j-th column, rows is the number of rows of the digital elevation model, and cols is the number of columns of the digital elevation model; fdir(i,j) represents the grid flow direction of the pixel of the i-th row and j-th column, offset(·) represents the number offset between the upstream pixel and the downstream pixel, and dir(·) represents the corresponding relationship between the upstream pixel and the downstream pixel; S5.
2. Analyze the grid flow matrix fdir to construct the relationship between the downstream pixels and the upstream pixels; the expression is as follows: dir inverse (pixel i,j )={pixel m,n |dir(pixel m,n )=pixel i,j } In the formula, dir inverse (·) indicates the correspondence between downstream pixels and upstream pixels, pixel m,n Indicates that the downstream pixel is pixel i,j The upstream pixel of this condition; S5.3, constructing a multi-branch tree of flow directions according to the corresponding relationship between the upstream pixels and the downstream pixels, and the relationship between the downstream pixels and the upstream pixels; S6, iteratively traverse the lake distribution data, extract edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixel as the starting pixel to perform subtree layer traversal using the flow multi-branch tree to extract the lake basin boundary; the specific steps include: S6.1, iteratively traverse the lake distribution data, extract the outer boundary line of the lake vector, and convert the outer boundary line from vector data to raster data to extract the edge pixels corresponding to the lake; S6.
2. Take the edge pixel corresponding to the lake as the starting pixel and use the flow multi-branch tree to perform subtree layer traversal; wherein, after querying the upstream pixel of the starting pixel, take the current upstream pixel as the starting pixel again, and extract iteratively back and forth to obtain the lake basin boundary.
2. The inland lake basin extraction method according to claim 1, It is characterized in that In the step S2, the step of calculating the initial grid flow direction of each pixel in the digital elevation model of the target area includes: S2.
1. Calculate the elevation difference between each pixel and the surrounding eight pixels in the digital elevation model of the target area; S2.2, dividing the elevation difference between each pixel and its adjacent pixel by the distance between the pixels, and calculating the slope between the pixels; S2.
3. According to the slope between each pixel, set the direction along the maximum slope as the initial grid flow direction.
3. The inland lake basin extraction method according to claim 2, It is characterized in that In the step S2, the step of selecting pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set includes: Traverse each pixel in the digital elevation model and make a judgment: if the elevation value of the current pixel is lower than the surrounding 8 pixels, or the elevation difference between the current pixel and the surrounding 8 pixels is negative, then the current pixel is judged as a pixel whose flow direction cannot be determined, the current pixel is added to the depression pixel set, and the current pixel is filled with a preset depression pixel filling value.
4. The inland lake basin extraction method according to claim 3, It is characterized in that In the step S3, the step of identifying the land surface depressions and lake depressions in the depression pixel set according to the lake distribution data includes: S3.
1. Extract corresponding pixel numbers according to the depression pixel set to form a depression pixel number set sink total ; Its expression is as follows: sink total ={pixels i,j |flowdir i,j =fill value} pixel i,j =i*rows+j In the formula, pixel i,j Indicates the pixel number of the i-th row and j-th column, flowdir i,j Indicates the flow direction of the pixel in the i-th row and j-th column, fillvalue is the preset depression pixel filling value; rows is the number of rows of the digital elevation model, and cols is the number of columns of the digital elevation model; S3.
2. According to the lake distribution data, the kth lake is converted from a vector to a raster with the same shape and resolution as the original digital elevation model, where the pixels covered by the lake are 1 and the pixels not covered by the lake are 0, and the mask matrix mask of the kth lake is obtained. lake,k ; S3.3, sink from the depression pixel number set total Extract the depressions covered by lakes, and after traversing all lake distribution data, obtain the lake depression pixel set and the land depression pixel set; its expression is as follows: In the formula, sink lake,k represents the set of depression pixels covered by the kth lake, where sink lake,k A value of 0 indicates that the pixel belongs to a land depression pixel. lake,k A value of 1 indicates that the pixel belongs to a lake depression pixel; sink t Represents the sink pixel number set total The tth pixel in ; According to the sink lake,k The values of are divided into a set of land depression pixels and a set of lake depression pixels.
5. The inland lake basin extraction method according to claim 4, It is characterized in that The step S3 further includes the following steps: After identifying the set of depression pixels covered by the kth lake, the elevation of each pixel is queried through the digital elevation model, and the pixel with the smallest elevation value is retained; its expression is as follows: sink′(sink t |them sinkt min(them). sink1 ,them sink2 ,...,they sinkn ) sink 1 ,sink 2 ,...,sink n ∈sink lake,k Where sink' represents the lowest depression covered by the kth lake, and dem sinkt Indicates sink t The corresponding elevation; After repeating the above operation for all lakes, we get the lowest sink of all lakes. lowest , and then obtain the land surface depression set sink through difference calculation land =sink total --sink lowest .
6. The inland lake basin extraction method according to any one of claims 1 to 5, It is characterized in that In the step S4, the specific steps include: S4.
1. Convert the lake depression pixel set into a mask array with the same shape and resolution as the original digital elevation model. sink ; Mask array mask sink In the above figure, the pixels belonging to lake depressions are marked as 1, and the pixels not belonging to lake depressions are marked as 0; S4.2, according to the mask array mask sink , fill and remove the depression marked as 0; S4.3, after filling the mask array mask sink Perform flow direction calculation and obtain the grid flow direction matrix fdir in the digital elevation model.
7. An inland lake basin extraction system based on a digital elevation model, applied to the inland lake basin extraction method according to any one of claims 1 to 6, It is characterized in that include: Data acquisition module, used to obtain digital elevation models and lake distribution data of the target area; A depression identification module is used to calculate the initial grid flow direction of each pixel in the digital elevation model of the target area, and select pixels whose flow direction cannot be determined according to the initial grid flow direction to form a depression pixel set; and to identify land depressions and lake depressions in the depression pixel set according to the lake distribution data, and output a land depression pixel set and a lake depression pixel set; A depression filling module is used to selectively fill corresponding land depression pixels in the digital elevation model, and then calculate the grid flow direction and output the grid flow direction matrix; A flow direction multi-branch tree construction module, used for parsing the grid flow direction matrix and constructing a flow direction multi-branch tree; The lake basin boundary extraction module is used to iteratively traverse the lake distribution data, extract the edge pixels corresponding to the outer boundary line of the lake vector, and then use the lake edge pixels as the starting pixels to perform subtree layer traversal using the flow multi-branch tree to output the extracted lake basin boundary data.
8. An inland lake basin extraction system based on a digital elevation model, comprising a memory and a processor, wherein the memory stores a computer program, It is characterized in that When the processor executes the computer program, the steps of the inland lake basin extraction method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Large river valley depression filling preprocessing method based on grid DEM
CN104537718A
Digital elevation model-based city depression extraction method
CN107305701A