A method for querying obstacle points across maps based on GDAL management DEM

By using virtual raster datasets (vrt) and the GDAL library to manage DEM data, the tedious problems of DEM data organization and cross-map query in route planning are solved, efficient obstacle point query is achieved, and the performance requirements of the onboard computer are met.

CN117235196BActive Publication Date: 2025-10-21XIAN AVIATION COMPUTING TECH RES INST OF AVIATION IND CORP OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311062815.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-22
Publication Date
2025-10-21
Estimated Expiration
2043-08-22

AI Technical Summary

Technical Problem

In existing technologies, the organization of DEM data and cross-map query methods in route planning are cumbersome, and due to the limited CPU and memory of onboard computers, the memory consumption is large and the query algorithm is slow.

Method used

Virtual raster datasets (vrt) are used to organize DEM data. DEM data is managed through the GDAL library to avoid cutting into tiles. vrt files are used for cross-graph queries. LZW compression and lazy loading mechanisms are combined to optimize the query algorithm.

Benefits of technology

It simplifies DEM data management and maintenance, improves the versatility and efficiency of query algorithms, and meets the performance requirements of onboard computers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117235196B_ABST
    Figure CN117235196B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of route planning, and particularly relates to a method for querying obstacle points based on GDAL management DEM, which is based on the existing organization DEM data and cross-map query method, and proposes to use virtual raster dataset (vrt) to organize data, so that a large amount of DEM data can be avoided to be cut into tiles, and data management and maintenance work can be simplified. In terms of cross-map query, a separate query algorithm does not need to be designed, and the vrt file can be queried like a single image, so that the query algorithm design is simplified and is more universal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of route planning, and in particular relates to a method for querying obstacle points across maps based on GDAL management of DEM. Background Art

[0002] In route planning, terrain elevation data stored in a DEM is used to query for obstacles on the ground. By comparing the elevation with the obstacle height, the obstacle is determined and the presence and distribution of obstacles in the returned area are determined. Existing cross-graph query methods organize DEM data by tiling and splicing it into a large graph, and query methods include quadtree indexing and parallel querying. These methods are relatively cumbersome. Furthermore, given the limited CPU and memory available onboard computers, memory consumption needs to be minimized, and query algorithms must meet certain responsiveness requirements. Summary of the Invention

[0003] In light of this, the present invention provides a method for cross-map querying of obstruction points based on GDAL-based DEM management. Building on existing methods for organizing DEM data and cross-map querying, this method proposes using virtual raster datasets (VRTs) to organize data. This method avoids the need to slice large amounts of DEM data into tiles, simplifying data management and maintenance. For cross-map queries, there's no need to design a separate query algorithm; queries can be performed within the VRT file, just as with a single image. This simplifies query algorithm design and makes it more versatile.

[0004] In order to achieve the above technical objectives, the specific technical solutions adopted by the present invention are:

[0005] A method for querying obstacle points across maps based on GDAL management of DEM includes the following steps:

[0006] S101: merging multiple DEM small images into a large image, removing the overlapping parts between the DEM small images during merging; wherein, the maximum elevation among the overlapping pixels is taken as the elevation of the pixel;

[0007] S102: assigning the value of the pixel without data to the maximum value;

[0008] S103: Divide the large image into m rows and n columns of small images; create a vrt file for the divided small images using the GDAL library, read the vrt file to obtain all elevation data; and then obtain the coordinates of the DEM data range;

[0009] S104: Obtain an obstacle point matrix based on an obstacle query algorithm.

[0010] Furthermore, the values ​​of m and n are determined based on the size of the query area, the number of thumbnails, the size of the thumbnails, and the memory of the computer;

[0011] When the proportion of the query area to the target area is less than a first preset value, the target area is cut into small images for querying, and the size of the small images is set to be as large as possible without exceeding the computer memory limit, and the small images cover the query area as much as possible;

[0012] When the proportion of the query area to the target area is greater than a second preset value, the large image is directly read;

[0013] The first preset value and the second preset value are set to maximize the query speed for the target area.

[0014] Furthermore, before using GDAL to read the vrt file, set the thread and GDAL cache size to improve reading efficiency; in GDAL, specify the number of concurrent threads by setting the GDAL_NUM_THREADS environment variable, and specify the maximum cache size with the GDAL_CACHEMAX environment variable.

[0015] Furthermore, the DEM data is saved based on the LZW compression format.

[0016] Furthermore, the method for obtaining the obstacle point matrix based on the obstacle query algorithm specifically includes the following steps:

[0017] S201: Determine whether the query area intersects with the DEM and whether the query is valid. If the query area is completely out of bounds, no grid is divided and the program returns -1 as an error. When the query area intersects or is tangent to the longitude and latitude of the DEM, load the elevation data of the intersection area between the query area and the DEM. Then, further divide the query area into grids and record the number of each grid, the coordinates of the upper left corner point A and the lower right corner point C.

[0018] S202: Query all obstacle points in the intersection area. Obstacle points are points with elevations greater than or equal to the obstacle height. Then, find the grid numbers to which the obstacle points belong. At the same time, find the grid numbers in the query area that are outside the DEM boundary and intersect or tangent to the DEM, and record them in the obstacle grid number set.

[0019] S201: Remove duplicate obstacle point grid numbers. If there is an obstacle point in a grid, it is recorded as an obstacle grid.

[0020] S203: Assign all values ​​of the 0-1 matrix to 0; if there are obstacle grids, modify the values ​​in the 0-1 matrix corresponding to the grids with obstacle points, grids outside the DEM boundary, and grids intersecting or tangent to the DEM to 1, and the safe grid values ​​remain unchanged at 0 to obtain the final 0-1 matrix.

[0021] By adopting the above technical solution, the present invention can bring the following beneficial effects:

[0022] Building on existing methods for organizing DEM data and cross-image queries, this paper proposes using virtual raster datasets (VRTs) to organize data. This approach avoids the need to slice large amounts of DEM data into tiles, simplifying data management and maintenance. For cross-image queries, there's no need to design a separate query algorithm; queries can be performed within the VRT file, just as with a single image. This simplifies query algorithm design and makes it more versatile. To meet the performance requirements of the onboard computer, this paper proposes several optimization methods. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0024] Figure 1 This is a flow chart of the DEM dataset preprocessing and obstacle query algorithm based on the present invention. DETAILED DESCRIPTION

[0025] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0026] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.

[0027] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on this disclosure, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement an apparatus and / or practice a method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this apparatus and / or practice this method.

[0028] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The illustrations only show components related to the present disclosure and are not drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component can be changed at will, and the component layout type may also be more complicated.

[0029] Additionally, in the following description, specific details are provided to provide a thorough understanding of the examples. However, one skilled in the art will appreciate that the aspects described can be practiced without these specific details.

[0030] In one embodiment of the present invention, the query area is rectangular and does not rotate by default, that is, it faces due north and due south. Given the northwest point P1 and the southeast point P2, the entire query range can be determined. The target area is the area flown in this mission, which is composed of multiple DEM images in TIF format. The query area is divided into m×n grids according to the grid size. If there is a DEM elevation value in the grid that is greater than or equal to the obstacle height, the entire small grid is regarded as an obstacle grid and marked as 1. If it is safe, it is marked as 0, and finally the 0-1 matrix is ​​returned. The proposed query area is 30×30km, the grid size is 500×500m, and the target area is 1000×1000km.

[0031] This embodiment provides a method for querying obstacle points across graphs based on GDAL management of DEM. Figure 1 As shown, the following steps are included:

[0032] First, the DEM dataset is preprocessed.

[0033] Merge multiple small DEM images into a larger one. Because these images overlap at their boundaries, the overlap needs to be removed. The pixel values ​​in the overlapping area should retain the maximum elevation of the overlapping region as the elevation of that location. This is because the goal is to find all pixels in the area that are higher than the obstacle height to ensure flight safety.

[0034] Assign the value of no-data pixels to 99999. Multiple DEM images may be combined into an irregular target area. The merged DEM image is the minimum bounding rectangle of the target area, where the pixel values ​​of the target area remain unchanged, and the pixel values ​​of the surrounding or empty areas without data are nodata. Nodata cannot be read in the program, and the areas without data are themselves located within the minimum bounding rectangle. It is impossible to determine whether they are out of bounds based on the latitude and longitude range of the target area. In order to prevent aircraft from flying into map areas with no data and causing danger, the pixel values ​​of no data need to be set to very large abnormal values, such as 99999. In the subsequent obstacle query algorithm, the pixel values ​​of this part will be greater than the obstacle height and will be identified as an obstacle area to ensure aircraft safety.

[0035] The large image is re-divided into m rows and n columns of smaller images. Using the GDAL library, virtual real-time (VRT) files are created for these smaller images. The VRT files are read to obtain the complete elevation data, and the coordinates of the DEM data range are obtained. These four steps involve several technical key points: 1) how to determine m and n, 2) the advantages of using VRT files to organize and manage DEM data, which involves GDAL's cross-image query mechanism, and 3) using lossless LZW compression to store DEMs to save space. These are explained in detail below:

[0036] The GDAL library is a library specifically designed for processing raster data. The vrt file merges multiple small images into a logical dataset. It does not contain actual raster data, but is just a metadata file that contains a reference to the original dataset while retaining the metadata and georeference information of the original dataset without actually merging these small images. You can use vrt files like ordinary raster data, and operations are automatically applied to the original dataset contained in the vrt file. Therefore, we do not need to merge all the small images into a large image, and a large image of 1000×1000km cannot be loaded into memory, which provides us with convenience.

[0037] In addition, in the actual query process, there may be cross-map queries, which means that the query area may span multiple small maps. The values ​​of m and n are related to how GDAL uses the vrt file cross-map query mechanism. When using vrt files for cross-map queries, GDAL regards the vrt file as a whole dataset, rather than a separate data source, and will automatically cross the boundaries of small maps. Therefore, when a query range is given, GDAL will calculate which small maps to query based on the query range and DEM resolution, read and load multiple small maps from the disk, combine them into a logical dataset, and return the query results. Therefore, we do not need to design how the small maps are organized and stored on the electronic disk. GDAL can manage all small maps using vrt files, and can accurately find which small maps to load, solving the problem of cross-map queries for us.

[0038] When the query area contains a large number of small images, virtual raster datasets may cause some performance problems. To avoid this problem, GDAL uses a lazy loading mechanism when processing vrt files. This means that GDAL only loads the necessary small images when needed, and only the pixels within the query area will be loaded, and read and combined when needed, instead of loading all the small images into memory when opening the vrt file. This lazy loading mechanism can minimize unnecessary memory overhead. This mechanism of GDAL allows us to not worry about adding all the small images included in the cross-map query into memory, which is very space-saving. The loaded data will only be related to the size of the query area. When the query area is fixed, if the vrt file contains more small images, the more small images GDAL needs to read, so there will be more IO operations and the query speed will be slower.

[0039] When slicing an image, choosing m rows and n columns determines the size of the tiles. The choice of m and n requires consideration of several factors, including the size of the query area, the number of tiles, the tile size, and computer memory. Based on GDAL's cross-graph query mechanism, some tips are provided here. When the query area is much smaller than the target area, consider slicing the target area into tiles for querying to avoid reading too much data. When the query area is large, the tiles are also large, or the number of tiles is small, there's no need to use tiles; simply read the large image directly, as multiple I / O operations can slow down the query. Tile sizes should be as large as possible, but should not exceed computer memory limits. Tile sizes should cover the query area as much as possible to minimize I / O operations. The number of tiles should be kept as small as possible to avoid excessive I / O operations when querying across graphs. You can test multiple tile sizes and query area sizes, recording the memory usage and runtime of the algorithm, and continuously adjusting the algorithm to achieve the fastest query speed possible, ensuring that the algorithm meets the required timing requirements and meets the actual requirements.

[0040] In addition, before using GDAL to read the vrt file, set up multithreading and GDAL's cache size to improve reading efficiency. In GDAL, use the GDAL_NUM_THREADS environment variable to specify the number of concurrent threads and the GDAL_CACHEMAX environment variable to specify the maximum cache size in bytes. These parameters need to be adjusted based on the specific situation.

[0041] Throughout the entire processing process, DEM data is saved using the LZW compression format. Lossless image compression is required for each of the three steps: merging small images into a large image, assigning pixel values ​​of 99999 to pixels without data, and slicing the large image into small images. LZW compression reduces the image size on disk, thereby increasing file access speed. Saving space is essential for onboard electronic disks, which can accommodate more data. Although the generated small images are of the same size, the file size is related to the stored elevation fluctuations. When all pixel values ​​of the small images are 99999, the image compression rate is very high. However, some narrow target areas, when filled into rectangles, will have many small images without data around them. In such cases, compression is essential, significantly reducing storage space. It also improves image compression when the terrain is flat. Furthermore, pyramids can be constructed on these DEM data to speed up image browsing and display.

[0042] At this point, the DEM preprocessing is completed.

[0043] In the obstacle query algorithm, the first step is to determine whether the query area intersects the DEM and whether the query is valid. If it is completely out of bounds, no grid is created, and the program returns a -1 error. If both the longitude and latitude of the two areas intersect or are tangent, it indicates overlap, and the elevation data for the intersecting area between the query area and the DEM is loaded. The query area is further divided into a grid, and the coordinates of each small grid cell, including the upper left corner point A and the lower right corner point C, are recorded.

[0044] Next, search for all obstacle points within the intersecting area—points with elevations greater than or equal to the obstacle height. After finding the grid number to which the obstacle point belongs, you also need to find the grid numbers outside the DEM boundary and the grid numbers that intersect or are tangent to the DEM within the query area and add these to the set of obstacle grid numbers. Duplicate obstacle grid numbers are removed. Since multiple obstacle points can exist within a grid, duplicate obstacle grid numbers within the same grid are necessary. A grid is considered an obstacle grid if it contains at least one obstacle point. Assign all values ​​to the 0-1 matrix to zero. Since aircraft fly at high altitudes, obstacles are rare. Therefore, assigning all grids within the query area to zero reduces the number of times they are changed to 1.

[0045] Finally, if there are any obstruction grids, the values ​​in the 0-1 matrix corresponding to the grids with obstruction points, the grids outside the DEM boundary, and the grids intersecting or tangent to the DEM are modified to 1, and the values ​​of the safe grids remain unchanged at 0. The final 0-1 matrix is ​​obtained.

[0046] The present invention manages DEM data through GDAL, which can facilitate the query of obstacle points in a specified area. At the same time, it also provides a solution for cross-map query and suggestions for setting the query area size and grid size.

[0047] A specific method of preprocessing the DEM dataset in this embodiment

[0048] 1) Multiple DEM small images are merged into a large image;

[0049] Using the "Mosaic to New Raster" tool in Arc GIS, we combined all the small images into a large image. The pixel type and pixel size of the merged large image remained the same as those of the original small images. The "MAXIMUM" mosaic operator was selected to retain the maximum elevation value of the overlapping pixels as the new elevation value for that pixel. Furthermore, to reduce the file size of the merged large image, we constructed a pyramid and compressed the output large image, using lossless LZW compression. Finally, we obtained a large image with no overlapping pixels in the target area.

[0050] 2) Assign the value of the pixel with no data to 99999;

[0051] Use the raster calculator of Arc GIS to assign the nodata pixel value to 99999. Similarly, build a pyramid for the output large image and select LZW for lossless compression.

[0052] 3) Re-divide the large DEM image into small images;

[0053] In Global Mapper, use the Export to Grid tool to export a large DEM with no-data pixels set to 99999, with m rows and n columns. This will produce m x n smaller DEM images. Set the pixel type and pixel size of the exported smaller images to match the original data, and select LZW lossless compression.

[0054] 4) Use GDAL's gdalbuildvrt command line tool to generate a vrt file;

[0055] 5) Read the vrt file to obtain all DEM elevation data;

[0056] Use GDAL to read the vrt file containing all the small images and return all the DEM elevation datasets in the vrt.

[0057] 6) Get the DEM data range coordinates

[0058] By default, all DEM data in vrt is not rotated, that is, it faces due north and due south. The northwest point of the dataset is recorded as D1, and the southeast point is recorded as D2. Use GDAL to read the latitude and longitude of point D1 in the dataset, as well as the horizontal resolution, vertical resolution, number of pixels in the horizontal direction, and number of pixels in the vertical direction, and calculate the latitude and longitude of point D2, the southeast point.

[0059] 2. Obstacle Query Algorithm

[0060] Because the Earth is spherical and deformation varies with latitude, the grid size is measured in degrees. Since the DEM resolution is in degrees and does not deform with latitude, the grid size is measured in degrees rather than meters. For a 500m grid size, the degree of the grid is calculated by converting 1 degree to km. Similarly, for a 30km query area, the P1P2 latitude and longitude coordinates of the query area are also calculated. The algorithm input and output parameters are shown in Table 1.

[0061] Table 1 List of input and output parameters of the query barrier algorithm

[0062]

[0063] The specific steps of the query barrier algorithm are:

[0064] 1) Determine whether the query area P1P2 intersects with the DEM range D1D2;

[0065] 2) Load the elevation data of the query area and the DEM intersection area from the entire DEM data dataset;

[0066] Extract the elevation values ​​in the intersecting area according to the DEM resolution.

[0067] 3) Divide the query area into grids according to the grid size;

[0068] If the length and width of the query area do not divide the grid size, the last column or row of the grid is filled in. Get the row and column numbers of the grid within the query area. The grids are numbered from left to right and from top to bottom, starting at 0.

[0069] 4) Within the query area, record the number of each small grid, the latitude and longitude of point A in the upper left corner, and point C in the lower right corner;

[0070] 5) Find all the obstacles in the intersection area;

[0071] When the elevation is greater than or equal to the obstacle height, save the longitude and latitude of these obstacle points.

[0072] 6) Find the grid number to which the obstacle point belongs;

[0073] Traverse all obstacle points, calculate the row and column numbers of the grid to which the obstacle point belongs, calculate the grid number to which it belongs, and record it in the obstacle grid number set.

[0074] 7) Find the grid number of the DEM boundary and the grid number that intersects or is tangent to the DEM;

[0075] Traverse all small grids, and by comparing the longitude and latitude of small grid points A and C with the longitude and latitude of the DEM range D1D2, find the grid numbers that are out of bounds and intersect or tangent with the DEM, and record them in the obstacle grid number set.

[0076] 8) Remove duplicate obstacle point grid numbers;

[0077] 9) Assign all values ​​of the 0-1 matrix to 0;

[0078] 10) Change the value of the obstacle grid in the 0-1 matrix to 1.

[0079] The above description is merely a specific embodiment of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this disclosure should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.

Claims

1. A method for querying obstacle points across maps based on GDAL management of DEM, characterized in that: The following steps are involved: S101: merging multiple DEM small images into a large image, removing the overlapping parts between the DEM small images during merging; wherein, the maximum elevation among the overlapping pixels is taken as the elevation of the pixel; S102: assigning the value of the pixel without data to the maximum value; S103: Divide the large image into m rows and n columns of small images; create a vrt file for the divided small images using the GDAL library, read the vrt file to obtain all elevation data; and then obtain the coordinates of the DEM data range; S104: Obtaining an obstacle point matrix based on an obstacle query algorithm; Before using GDAL to read the vrt file, set the thread and GDAL cache size to improve reading efficiency; in GDAL, specify the number of concurrent threads by setting the GDAL_NUM_THREADS environment variable, and specify the maximum cache size by using the GDAL_CACHEMAX environment variable; The method for obtaining the obstacle point matrix based on the obstacle query algorithm specifically includes the following steps: S201: Determine whether the query area intersects with the DEM and whether the query is valid. If the query area is completely out of bounds, no grid is divided and the program returns -1 as an error. When the query area intersects or is tangent to the longitude and latitude of the DEM, load the elevation data of the intersection area between the query area and the DEM. Then, further divide the query area into grids and record the number of each grid, the coordinates of the upper left corner point A and the lower right corner point C. S202: Query all obstacle points in the intersection area. Obstacle points are points with elevations greater than or equal to the obstacle height. Then, find the grid numbers to which the obstacle points belong. At the same time, find the grid numbers in the query area that are outside the DEM boundary and intersect or tangent to the DEM, and record them in the obstacle grid number set. S203: Remove duplicate obstacle point grid numbers. If there is an obstacle point in the grid, it is recorded as an obstacle grid; S204: Assign all values ​​of the 0-1 matrix to 0; if there are obstacle grids, modify the values ​​in the 0-1 matrix corresponding to the grids with obstacle points, grids outside the DEM boundary, and grids intersecting or tangent to the DEM to 1, and the safe grid values ​​remain unchanged at 0 to obtain the final 0-1 matrix.

2. The method for cross-graph querying obstacle points based on GDAL management of DEM according to claim 1 is characterized in that: The values ​​of m and n are determined based on the size of the query area, the number of small graphs, the size of the small graphs, and the computer's memory; When the proportion of the query area to the target area is less than a first preset value, the target area is cut into small images for querying, and the size of the small images is set to be as large as possible without exceeding the computer memory limit, and the small images cover the query area as much as possible; When the proportion of the query area to the target area is greater than a second preset value, the large image is directly read; The first preset value and the second preset value are set to maximize the query speed for the target area.

3. The method for cross-graph querying obstacle points based on GDAL management of DEM according to claim 2 is characterized in that: DEM data is saved based on the LZW compression format.

Citation Information

Patent Citations

  • Mass raster data format conversion parallel method based on abstract data model

    CN102567508A

  • Parallel mode grid image slicing method

    CN105550977A