Disclosure of Invention
The embodiment of the application aims to provide a visualization method and device for irregular raster data, an electronic device and a computer-readable storage medium, which are used for realizing visualization presentation of the irregular raster data.
In one aspect, the present application provides a method for visualizing irregular raster data, including:
constructing a regular grid matched with irregular grid data according to the resolution and the coverage range of the irregular grid data to be processed;
determining grids to be assigned according to the region properties corresponding to each grid in the regular grids;
for each grid to be assigned in the regular grids, assigning the grid to be assigned according to the variable value of the target grid which is closest to the grid to be assigned in the irregular grid data to obtain regular grid data;
and after the regular raster data are converted into a specified data format, performing visual presentation according to the converted regular raster data.
In an embodiment, before said building a regular grid adapted to said irregular grid data, said method further comprises:
acquiring the irregular raster data; wherein the irregular grid data includes spatial information and variable values for each grid.
In one embodiment, the irregular raster data includes at least two types of raster data to be processed;
the method for constructing the regular raster matched with the irregular raster data according to the resolution and the coverage range of the irregular raster data to be processed comprises the following steps:
determining the maximum resolution and the maximum coverage range from the raster data to be processed;
determining a resolution level to which the maximum resolution belongs and a specified resolution corresponding to the resolution level;
and constructing the regular grid according to the specified resolution and the maximum coverage range.
In an embodiment, the assigning, for each to-be-assigned grid in the regular grids, the to-be-assigned grid according to a variable value of a target grid in the irregular grid data that is closest to the to-be-assigned grid to obtain regular grid data includes:
aiming at each grid to be assigned in the regular grids, calculating Euclidean distance according to the spatial information of the grid to be assigned and the spatial information of each grid in the irregular grid data;
for each grid to be assigned, determining the closest grid as a target grid according to a plurality of Euclidean distances corresponding to the grid to be assigned;
and assigning the grid to be assigned corresponding to the target grid according to the variable value of the target grid to obtain the regular grid data.
In one embodiment, the regional properties include ocean and land;
determining the grids to be assigned according to the region properties corresponding to each grid in the regular grids comprises the following steps:
determining a local vector map with the same coverage range from preset vector maps according to the coverage range of the irregular raster data; wherein the vector map indicates a marine corresponding region and a land corresponding region;
and taking the local vector map as a mask of the regular grid, and determining the grid with the regional property of the sea in the regular grid as the grid to be assigned.
In another aspect, the present application further provides a device for visualizing irregular raster data, including:
the building module is used for building a regular grid matched with the irregular grid data according to the resolution and the coverage range of the irregular grid data to be processed;
the determining module is used for determining the grids to be assigned according to the region properties corresponding to each grid in the regular grids;
the assignment module is used for assigning the grids to be assigned according to the variable values of the target grids which are closest to the grids to be assigned in the irregular grid data to obtain regular grid data;
and the display module is used for converting the regular raster data into a specified data format and then performing visual presentation according to the converted regular raster data.
In one embodiment, the irregular raster data includes at least two types of raster data to be processed;
the building module is further configured to:
determining the maximum resolution and the maximum coverage range from the raster data to be processed;
determining a resolution level to which the maximum resolution belongs and a specified resolution corresponding to the resolution level;
and constructing the regular grid according to the specified resolution and the maximum coverage range.
In one embodiment, the regional properties include ocean and land;
the determining module is further configured to:
determining a local vector map with the same coverage range from preset vector maps according to the coverage range of the irregular raster data; wherein the vector map indicates a marine corresponding region and a land corresponding region;
and taking the local vector map as a mask of the regular grid, and determining the grid with the regional property of the sea in the regular grid as the grid to be assigned.
Further, the present application also provides an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the method of visualizing the irregular raster data.
In addition, the present application also provides a computer readable storage medium, wherein the storage medium stores a computer program, and the computer program can be executed by a processor to complete the visualization method of the irregular raster data.
In the embodiment of the application, after the adaptive regular grids are constructed for the irregular grid data to be processed, the grids to be assigned are determined according to the region properties corresponding to each grid in the regular grids, and the grids to be assigned can be assigned according to the variable values of the target grids closest to the grids to be assigned in the irregular grid data for each grid to be assigned, so that the regular grid data is obtained; and after the regular raster data are converted into the specified data format, performing visual presentation according to the converted regular raster data. Compared with an interpolation method, the scheme of the application greatly reduces the implementation complexity, avoids the interference of manual parameter adjustment on visual presentation, and realizes the visual presentation of non-raster data.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Fig. 1 is a schematic application scenario diagram of a visualization method for irregular raster data according to an embodiment of the present application. As shown in fig. 1, the application scenario includes a client 20 and a server 30; the client 20 may be an electronic device such as a host, a mobile phone, a tablet computer, and the like, and is configured to initiate a visualization request to the server 30, where the visualization request carries irregular raster data to be displayed; the server 30 may be a server, a server cluster, or a cloud computing center, and may parse the irregular raster data from the visualization request and perform visual presentation on the irregular raster data.
As shown in fig. 2, the present embodiment provides an electronic apparatus 1 including: at least one processor 11 and a memory 12, one processor 11 being exemplified in fig. 2. The processor 11 and the memory 12 are connected by a bus 10, and the memory 12 stores instructions executable by the processor 11, and the instructions are executed by the processor 11, so that the electronic device 1 can execute all or part of the flow of the method in the embodiments described below. In an embodiment, the electronic device 1 may be the server 30 described above, and is configured to perform a visualization method of irregular raster data.
The Memory 12 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk.
The present application also provides a computer readable storage medium storing a computer program executable by a processor 11 to perform the method for visualizing irregular grid data provided herein.
Referring to fig. 3, a flowchart of a method for visualizing irregular raster data according to an embodiment of the present application is shown in fig. 3, where the method may include the following steps 310 to 340.
Step 310: and constructing a regular grid matched with the irregular grid data according to the resolution and the coverage range of the irregular grid data to be processed.
The irregular raster data can be sea ice data obtained through sounding observation, ground observation, model simulation and the like, and can also be downloaded directly from a sea ice information sharing platform. The sea ice data may be sea ice thickness data and sea ice intensity data.
The resolution of the raster data may be how many rasters are present in the raster data. Illustratively, the resolution is represented as 800 × 600 in width × height, indicating a total of 480000 grids in the grid data. For irregular grid data, the grid corresponding to sea ice data may be in a discrete state and not uniformly distributed.
If only one type of irregular raster data is to be processed, the server side can directly construct a regular raster according to the resolution and the coverage range of the irregular raster data. Illustratively, the server obtains sea ice thickness data with a resolution of 720 × 256 in width × height, and the sea ice thickness data covers latitude ranging from 26 degrees north latitude to 90 degrees north latitude and longitude ranging from 180 degrees west longitude to 180 degrees east longitude. The server side can construct a regular grid with the resolution of 720 x 256, the coverage range of 26 degrees north latitude to 90 degrees north latitude, and the longitude range of 180 degrees west longitude to 180 degrees east longitude.
If there are at least two types of irregular raster data to be processed, each of the irregular raster data may be regarded as the raster data to be processed. Here, in one case, the at least two kinds of raster data to be processed may be both sea ice thickness data or both sea ice density data; in another case, the at least two types of raster data to be processed may include sea ice thickness data and sea ice density data.
The server can determine the maximum resolution and the maximum coverage range from the raster data to be processed. The server may check the resolution of each raster data to be processed, and thus select the maximum resolution. The server side can determine the maximum width and the maximum height from all the raster data to be processed, so that the maximum resolution is constructed according to the maximum width and the maximum height. For example, the irregular raster data includes three types of raster data to be processed, the respective rates are respectively represented as 720 × 256, 480 × 256, and 800 × 200, and the server may determine that the maximum width is 800 and the maximum height is 256, so as to obtain the maximum resolution of 800 × 256. The server may check the coverage of each raster data to be processed, and select the maximum coverage. The server may check the coverage of each to-be-processed raster data and determine the maximum coverage with a collection of the coverage of all to-be-processed raster data.
The server may determine a resolution level to which the maximum resolution belongs and a specified resolution corresponding to the resolution level. The server may pre-configure a plurality of resolution levels, each resolution level corresponds to a resolution interval, the specified resolution is an optimal resolution for the resolution interval, and the specified resolution may be, for example, a maximum resolution in the resolution interval.
The server can construct a regular grid according to the specified resolution and the maximum coverage.
By the aid of the method, the server side can construct the grids with higher resolution ratio for the grid data to be processed, and accordingly subsequent visual display effect is improved.
Step 320: and determining the grids to be assigned according to the region properties corresponding to each grid in the regular grids.
In an embodiment, regional properties may include ocean and land.
When the server visually presents the sea ice data, the grid with the regional property of the sea can be used as the grid to be assigned.
Step 330: and assigning the grid to be assigned according to the variable value of the target grid which is closest to the grid to be assigned in the irregular grid data aiming at each grid to be assigned in the regular grids to obtain the regular grid data.
If the irregular grid data is sea ice thickness data, the variable value of the grid corresponding to the ocean region in the irregular grid data is a sea ice thickness value; if the irregular grid data is sea ice density data, the variable value of the grid corresponding to the sea area in the irregular grid data is the sea ice density value.
The target grid refers to the grid closest to the grid to be assigned in the irregular grid data.
Aiming at each grid to be assigned in the regular grids, the server side can determine a target grid closest to the grid to be assigned from at least one type of irregular grid data, and assigns the grid to be assigned according to the variable value of the target grid. And when the server assigns the grids to be assigned through the variable value of the target grid closest to each grid to be assigned, regular grid data can be obtained. The regular grid data allows the sea ice data to become continuous in spatial distribution.
Step 340: and after the regular raster data are converted into the specified data format, performing visual presentation according to the converted regular raster data.
Wherein the specified data format may be a data format for visual presentation. Illustratively, the specified data format may be a data format conforming to a three-dimensional WebGIS platform.
After the server side obtains the regular raster Data, the server side can endow the regular raster Data with spatial information through a GDAL (geographic spatial Data Abstraction Library) class Library, and convert the regular raster Data endowed with the spatial information into a specified Data format. Here, the spatial information given to the regular grid data is determined by the coverage and resolution corresponding to the regular grid. Illustratively, the coverage range is latitude range from 26 degrees of north latitude to 90 degrees of north latitude, the longitude range from 180 degrees of west longitude to 180 degrees of east longitude, and the resolution is 720 × 256, then the latitude difference between the two upper and lower rows of grids is 0.25 degrees, and the longitude difference between the two left and right columns of grids is 0.5 degrees, so that the longitude and latitude corresponding to each grid can be determined as the spatial information. The server can perform three-dimensional visual presentation on the regular raster data converted into the specified data format through the three-dimensional WebGIS platform.
Through the measures, the data quality of the sea ice data of the irregular grid can be improved, and a good three-dimensional visual presentation effect is achieved.
Before an embodiment, the server may obtain the irregular grid data before constructing the regular grid. Wherein the irregular grid data includes spatial information and variable values for each grid. The spatial information may be latitude and accuracy, and the variable value may be one or both of a sea ice thickness value and a poster density value.
After obtaining the irregular raster data, the server may process a subsequent raster that needs to be processed into data entries, where each data entry may include a raster number, a latitude, a longitude, and a variable value. The server can save the data items to a local spatial database PostGIS.
In an embodiment, when the server performs step 330, the local vector map with the same coverage range may be determined from the preset vector maps according to the coverage range of the irregular raster data. Wherein the vector map indicates a marine corresponding region and a land corresponding region. The vector map may include all possible coverage areas for the application scenario, which is illustratively the processing of sea ice data, and may include south and north poles. Referring to fig. 4, a schematic diagram of a local vector map provided in an embodiment of the present application is shown in fig. 4, where the coverage range of the local vector map is 26 degrees north latitude to 90 degrees north latitude, and the longitude range is 180 degrees west longitude to 180 degrees east longitude. In the local vector map, a region having the same color as the legend 0 represents land, and a region having the same color as the legend 1 represents sea.
The server side can use the local vector map as a mask of the regular grid, so that the grid with the regional property of the ocean in the regular grid is determined as the grid to be assigned. The server side can determine whether the area corresponding to each grid in the regular grid is ocean or land according to the local vector map, and therefore grids with the area property of being the rest are used as grids to be assigned.
In an embodiment, referring to fig. 5, a flowchart of a method for generating regular raster data provided in an embodiment of the present application is shown, and as shown in fig. 5, the method may include the following steps 510 to 530.
Step 510: and aiming at each grid to be assigned in the regular grids, calculating the Euclidean distance according to the spatial information of the grid to be assigned and the spatial information of each grid in the irregular grid data.
Aiming at each grid to be assigned in the regular grid, the server side can determine the latitude difference value and the longitude difference value of the grid to be assigned according to the spatial information of the grid to be assigned and the spatial information of each grid in the irregular grid data, and convert the latitude difference value and the longitude difference value into mileage, and further calculate the Euclidean distance according to the mileage in the latitude direction and the mileage in the longitude direction.
Step 520: and for each grid to be assigned, determining the closest grid as a target grid according to a plurality of Euclidean distances corresponding to the grid to be assigned.
Step 530: and assigning the grid to be assigned corresponding to the target grid according to the variable value of the target grid to obtain regular grid data.
The server side can determine a target grid closest to the grid to be assigned according to the Euclidean distance between the grid to be assigned and each grid in the irregular grid data, and then assigns the grid to be assigned according to the variable value of the target grid. And obtaining regular grid data after all grids to be assigned are assigned.
In practical application, the server can directly issue a query instruction to a spatial database storing data entries, so as to determine a target grid corresponding to a grid to be assigned, and then complete assignment.
The treatment effect of the present embodiment will be described below with reference to the drawings.
Referring to fig. 6, a schematic diagram of irregular grid data according to an embodiment of the present disclosure is shown, where fig. 6 shows sea ice data in a range from 26 degrees north latitude to 90 degrees north latitude, and from 180 degrees west longitude to 180 degrees east longitude. The image in the dotted line frame of fig. 6 is enlarged, and it can be found that the grid points are not uniformly distributed in space, and the grid points at high latitude are very sparse.
Referring to fig. 7, a schematic diagram of a regular grid according to an embodiment of the present application is provided, where the regular grid in fig. 7 is constructed according to the resolution and coverage of the irregular grid data in fig. 6. The image in the dotted line frame of fig. 7 is enlarged, and the grids to be assigned in the regular grids are uniformly distributed in space.
Referring to fig. 8, which is a schematic diagram of regular raster data provided in an embodiment of the present application, the regular raster data in fig. 8 is obtained by assigning values to the regular raster in fig. 7 according to the irregular raster data in fig. 6. The regular grid data in fig. 8 are distributed uniformly in space, and good visual presentation of the sea ice data can be realized.
Referring to fig. 9, a block diagram of an apparatus for visualizing irregular grid data according to an embodiment of the present application is provided, and as shown in fig. 9, the apparatus may include:
a constructing module 910, configured to construct a regular raster adapted to irregular raster data according to a resolution and a coverage of the irregular raster data to be processed;
a determining module 920, configured to determine a to-be-assigned grid according to a region property corresponding to each grid in the regular grids;
an assignment module 930, configured to assign, for each to-be-assigned grid in the regular grid, the to-be-assigned grid according to a variable value of a target grid, which is closest to the to-be-assigned grid, in the irregular grid data, to obtain regular grid data;
and a display module 940, configured to convert the regular raster data into a specified data format, and perform visual presentation according to the converted regular raster data.
In an embodiment, the apparatus further comprises an obtaining module 950 configured to:
acquiring the irregular raster data; wherein the irregular grid data includes spatial information and variable values for each grid.
In one embodiment, the irregular raster data includes at least two types of raster data to be processed;
a building module 910, further configured to:
determining the maximum resolution and the maximum coverage range from the raster data to be processed;
determining a resolution level to which the maximum resolution belongs and a specified resolution corresponding to the resolution level;
and constructing the regular grid according to the specified resolution and the maximum coverage range.
In one embodiment, the assignment module 930 is further configured to:
aiming at each grid to be assigned in the regular grids, calculating Euclidean distance according to the spatial information of the grid to be assigned and the spatial information of each grid in the irregular grid data;
for each grid to be assigned, determining the closest grid as a target grid according to a plurality of Euclidean distances corresponding to the grid to be assigned;
and assigning the grid to be assigned corresponding to the target grid according to the variable value of the target grid to obtain the regular grid data.
In one embodiment, the regional properties include ocean and land;
the determining module 920 is further configured to:
determining a local vector map with the same coverage range from preset vector maps according to the coverage range of the irregular raster data; wherein the vector map indicates a marine corresponding region and a land corresponding region;
and taking the local vector map as a mask of the regular grid, and determining the grid with the regional property of the sea in the regular grid as the grid to be assigned.
The implementation processes of the functions and actions of each module in the device are specifically described in the implementation processes of the corresponding steps in the visualization method of irregular raster data, and are not described herein again.
In the embodiments provided in the present application, the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.