A method for storing and reading continuous raster data
Through the methods of redivision and dynamic filtering, the problem of space occupation during continuous raster data storage and reading is solved, and more efficient data storage and transmission is achieved.
Patent Information
- Application Number
- CN202211159258.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2042-09-22
AI Technical Summary
The prior art occupies a large amount of storage space when storing and reading continuous raster data, resulting in high cost of system storage equipment and low network transmission efficiency.
By redividing the rows and columns of the original raster data, forming filter blocks, and using error control methods to dynamically filter cells, storing candidate cell marking data and values, reducing storage requirements.
It effectively reduces the amount of data storage, saves storage equipment costs, improves network transmission efficiency, and data compression efficiency is better than existing methods.
Smart Images

Figure CN115563107B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of raster data processing, and in particular to a method for storing and reading continuous raster data. Background Art
[0002] The raster data model divides the geographic space into a pixel array consisting of several rows and columns. The smallest unit is called a pixel or a pixel. The position of each pixel is determined by the row and column number, and the value of the pixel records a certain type of geographic attribute value at this position. Raster data with integer pixel values is usually used to store various discrete data or classified data. For example, in land use type raster data, each pixel stores an integer, representing the land use category of the geographic space corresponding to the pixel, such as integer 1 represents cultivated land, integer 2 represents forest land, integer 3 represents grassland, and so on. One of the characteristics of discrete raster data is that pixel values cannot be directly calculated by arithmetic. For example, it is meaningless to calculate the mean of two pixels with pixel values of 1 and 2 to obtain a pixel value of 1.5. Continuous raster data is a continuous raster data in which each pixel value has the characteristic of continuity. For example, in DEM raster data, any value between the maximum pixel value and the minimum pixel value can be used as a pixel value.
[0003] Assume that a continuous raster data is composed of K rows and L columns of raster pixels, and the numerical value corresponding to each raster pixel is a double floating point value. According to the common practice of the current raster data model, K*L*8 bytes are required. When the coverage area of the raster data is large and the resolution is high (such as each pixel corresponds to an area of 1 meter in length and width), the number of rows and columns of the raster K*L is large, and the required storage space is very large, which poses a great challenge to the system's storage device cost and network transmission efficiency. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for storing and reading continuous raster data, which can effectively reduce the amount of data storage, save storage device costs, and improve network transmission efficiency.
[0005] A method for storing continuous raster data, storing original classified raster data Data composed of K rows and L columns of pixels, comprising the following steps:
[0006] S1. Re-divide the rows and columns of the original classified raster data Data:
[0007] The rows and columns of the original raster data Data composed of K rows and L columns of pixels are re-divided with the screening area as the minimum granularity to obtain a rows and b columns of screening blocks;
[0008] When K / s 1 When it is an integer, a=K / s 1 ;
[0009] When K / s 1 When it is not an integer, a=[K / s 1 ]+1;
[0010] When L / s 2 When it is an integer, b=L / s 2 ;
[0011] When L / s 2 When it is not an integer, b=[L / s 2 ]+1;
[0012] Among them, the screening area is s 1 Lines 2 The raster data matrix of columns, s 1 、s 2 is a constant, s 1 >=3,s 2 >=3;
[0013] S2. For a row and b column screening blocks, the error control method is used to dynamically screen the pixels in each screening block, and the candidate pixel label data and candidate pixel values are stored in the data file Xdata;
[0014] S3. Record the starting position of the filter block in the first column of each row in the data file Xdata;
[0015] S4. Record metadata information of the original continuous raster data Data.
[0016] Furthermore, in S2, for the screening blocks with a rows and b columns, error control is used to perform dynamic pixel screening on the screening blocks one by one, which specifically includes the following steps:
[0017] Select multiple feature points as candidate pixels in the screening blocks with a rows and b columns;
[0018] Determine the maximum absolute error threshold e parameter value;
[0019] According to the candidate pixels, the maximum absolute error threshold e parameter value is used for interpolation calculation layer by layer to perform dynamic pixel screening.
[0020] Furthermore, the dynamic pixel screening specifically includes the following steps:
[0021] The middle pixel is selected between the candidate pixels, and the calculated value of the middle point pixel is calculated. It is determined whether the error between the calculated value of the middle pixel and its true value is within the maximum error threshold e. If so, the middle pixel is not used as a screening candidate pixel, otherwise the middle pixel is used as a candidate pixel; the screening is performed row by row and column by column until all pixels are screened.
[0022] Furthermore, in step 2, the candidate pixel label data and the candidate pixel value are stored in the data file Xdata; the byte size required for storing the current screening block is recorded as a value Ts, which is initially 0;
[0023] Mark the screening status of each pixel row by row and column by column in the screening block. If the pixel is a candidate pixel, set the marking data B[i][j]=1, otherwise set the marking data B[i][j]=0;
[0024] If 1 *s 2 It is a multiple of 8. The value of Ts is s 1 *s 2 / 8; if s 1 *s 2 If it is not a multiple of 8, that is, the tag data B[][] cannot be completely divided into an integer number of bytes, then a bit with a value of 0 is added to the end to make it a complete byte, and the value of Ts is [s 1 *s 2 / 8]+1;
[0025] The candidate pixel label data B[][] is written into the data file Xdata in bytes of Ts bytes; the pixel values of the candidate pixels screened above are written into the data file Xdata in sequence.
[0026] Furthermore, step 3 records the storage starting position of the filter block of the first column of each row in the data file Xdata, including the following steps: recording the cumulative value sumTs of the storage space size Ts of the filter blocks of each column in each row, and writing it into the data file rowSize.
[0027] Furthermore, in step 4, the metadata information includes: the number of rows K and the number of columns L of the original continuous raster data Data; the number of rows K and the number of columns L of the screening area s 1 、s 2 Value, maximum absolute error threshold e parameter value.
[0028] A method for reading continuous raster data is also provided, which is used to read the raster data stored according to the above-mentioned method for storing continuous raster data. If the raster unit data D(r, c) of the pixel value of the rth row and cth column of the original classified raster data Data is to be read, where 1<=r<=K, 1<=c<=L, the following steps are included:
[0029] Step 1. Read the data file meta, obtain the metadata information of the original continuous raster data Data, and obtain the number of rows K and columns L of the original continuous raster data Data; filter area s 1 、s 2value, the maximum absolute error threshold e parameter value, calculate that there are a rows and b columns of screening blocks in the data file Xdata;
[0030] Step 2. Calculate the number of the filter block where the pixel at the rth row and the cth column is located. Assume that the row number of the filter block where the requested pixel is located is v and the column number is z;
[0031] When r / s 1 When it is an integer, v = r / s 1 ;
[0032] When r / s 1 When it is not an integer, v = [r / s 1 ]+1;
[0033] When c / s 2 When it is an integer, z=c / s 2 ;
[0034] When c / s 2 When it is not an integer, z=[c / s 2 ]+1;
[0035] Step 3. Read the data file rowSize and obtain a integer values, e1, e2, ..., ea;
[0036] When v=1, the data of the first column of the first row of the filter block starts at byte 0 of the data file Xdata, and offset=0;
[0037] When v>1, the data of the first column of the filter block in the vth row starts at the e(v-1) byte of the data file Xdata, and offset=e(v-1);
[0038] The data file Xdata is read starting from the offset byte, and the information of the filter blocks is parsed one by one, so as to calculate the pixel value in the filter block where the requested pixel is located.
[0039] Furthermore, for step 3 of parsing the information of the filter blocks one by one, the parsing of the information of the filter blocks includes reading candidate pixel label data and reading candidate pixel value data.
[0040] Further, the information of the filter block is parsed to calculate the pixel value in the filter block where the requested pixel is located, which specifically includes the following steps:
[0041] If the current block being read is the jth filter block, 1<=j<=z;
[0042] Read candidate pixel label data:
[0043] If 1 *s 2If it is a multiple of 8, read s from the data file Xdata 1 *s 2 / 8 bytes are candidate pixel label data; if s 1 *s 2 If it is not a multiple of 8, read [s 1 *s 2 / 8]+1 byte, take the first s 1 *s 2 The bit data is the candidate pixel label data;
[0044] Read candidate pixel value data:
[0045] Cumulative 1 *s 2 The number of bits with a value of 1 in the bit candidate pixel mark data is m, and m double values v1, v2, v3, ..., vm are read from the data file Xdata, corresponding to s in the filter block respectively. 1 *s 2 m candidate pixel values;
[0046] If j==z, then interpolation is performed based on the m candidate pixel values to obtain all pixel values in the filter block;
[0047] If j!=z, the requested pixel is not in the filter block, and there is no need to parse the pixel value in the filter block, and the next column of filter block data is processed.
[0048] Furthermore, the interpolation calculation to obtain all pixel values in the filter block includes the following steps:
[0049] Before interpolating the middle pixel between two candidate pixels, determine whether the middle pixel value belongs to the candidate pixel. If it is a candidate pixel, no interpolation calculation is required, and the middle pixel value is directly determined to be the candidate pixel value. If not, the interpolation calculation result is used as the middle pixel value. Perform interpolation processing row by row for multiple times to obtain all pixel values in the screening block.
[0050] Then, according to the row and column numbers r and c of the requested pixel, the pixel position in the filter block is obtained, and then the pixel value is determined, and the reading is completed.
[0051] Compared with the prior art, the present invention has the following technical effects:
[0052] The present invention performs multi-level interpolation screening of row and column pixels according to the specified feature point pixel values. As long as the pixel values in a row or a column are partially close, there will be a data compression effect. It is independent of the initially specified feature point pixel values and has better data compression efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a schematic diagram of the overall structure of the system of the present invention. DETAILED DESCRIPTION
[0054] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.
[0055] Reference Figure 1 A method for storing continuous raster data is provided, wherein the original classified raster data Data consisting of K rows and L columns of pixels is stored. For the convenience of description, the row and column numbers of the pixels and blocks of the original classified raster data Data are counted starting from 1. In this application, the symbol [x] represents the maximum integer not greater than x.
[0056] The storage method of continuous raster data includes the following steps:
[0057] S1. Re-divide the rows and columns of the original classified raster data Data:
[0058] The rows and columns of the original raster data Data composed of K rows and L columns of pixels are re-divided with the screening area as the minimum granularity to obtain a rows and b columns of screening blocks;
[0059] When K / s 1 When it is an integer, a=K / s 1 ;
[0060] When K / s 1 When it is not an integer, a=[K / s 1 ]+1;
[0061] When L / s 2 When it is an integer, b=L / s 2 ;
[0062] When L / s 2 When it is not an integer, b=[L / s 2 ]+1;
[0063] Among them, the screening area is s 1 Lines 2 The raster data matrix of columns, s 1 、s 2 is a constant, s 1 >=3,s 2 >=3.
[0064] In a specific embodiment, the number of pixel rows s in the screening area 1 and the number of columns s 2 They can be unequal or equal. 1 =s 2=s, then the screening area consists of s rows and s columns of pixels. The original classified raster data Data is divided from top to bottom and from left to right with the screening area as the minimum granularity to obtain a rows and b columns of screening blocks.
[0065] When K / s is an integer, a=K / s;
[0066] When K / s is not an integer, a=[K / s]+1; if there are less than s rows of pixels in the a-th row of the screening block, the pixel value is 0 to supplement the number of s rows of pixels.
[0067] When L / s is an integer, b = L / s;
[0068] When L / s is not an integer, b=[L / s]+1; if the number of pixels in the b-th column of the screening block is less than s columns, the pixel value is 0 to supplement the number of pixels to s columns.
[0069] S2. For the screening blocks with a rows and b columns, use the maximum absolute error threshold e parameter value to perform dynamic pixel screening on each screening block, and store the candidate pixel label data and candidate pixel values in the data file Xdata.
[0070] The dynamic screening process of the screening block in row j and column q, 1<=j<=a, 1<=q<=b: the byte size required for storing the current screening block is recorded with the value Ts, which is initially 0, and specifically includes the following steps:
[0071] S2-1. Select multiple feature points as candidate pixels in the screening blocks with a rows and b columns;
[0072] In a specific embodiment, there are s in the selected filter block. 1 *s 2 pixels, and the pixel A in the first row and first column, the pixel S in the first row 2 Column pixel B, s 1 The first pixel of the row is C, the sth pixel 1 Line s 2 The four pixels in column pixel D are directly selected as candidate pixel points as feature points. Of course, other pixels can also be selected as feature points, and extension interpolation calculations are required when calculating certain pixel values.
[0073] S2-2. Determine the maximum absolute error threshold parameter value e;
[0074] The parameter value of the maximum absolute error threshold e can be set based on experience.
[0075] S2-3. According to the candidate pixels, the maximum absolute error threshold e parameter value is used for interpolation calculation layer by layer to perform dynamic pixel screening.
[0076] The middle pixel is selected between the candidate pixels, and the calculated value of the middle point pixel is calculated. It is determined whether the error between the calculated value of the middle pixel and its true value is within the maximum error threshold e. If so, the middle pixel is not used as a screening candidate pixel, otherwise the middle pixel is used as a candidate pixel; the screening is performed row by row and column by column until all pixels are screened.
[0077] In a specific embodiment, for the screening of the first row of pixels in the screening block:
[0078] For the first row of pixels, first interpolate and calculate the calculated value VM of the middle point pixel M based on the candidate pixels A and B, and compare whether the error between the value VM and the true value PM of the pixel M is within the maximum absolute error threshold e. If so, the middle point pixel M is not used as a candidate pixel for screening; otherwise, the pixel M is used as a candidate pixel. There is no specific restriction on the interpolation calculation method here, as long as it is consistent with the interpolation calculation during subsequent reading and analysis, and it is preferred to use a high-efficiency method such as linear interpolation.
[0079] For the pixels between pixel A and pixel M, the calculated value VS of the middle pixel S is also interpolated and compared to see whether the error between the value VS and the true value PS of pixel S is within the maximum absolute error threshold e. If yes, the middle pixel S is not used as a candidate pixel; otherwise, the pixel S is used as a candidate pixel.
[0080] For the pixels between pixel M and pixel B, the calculated value VT of the middle pixel T is also interpolated and calculated. The error between the comparison value VT and the true value PT of pixel T is within the maximum absolute error threshold e. If yes, the middle pixel T is not used as a candidate pixel; otherwise, pixel T is used as a candidate pixel.
[0081] Continue the same process to process the pixels between pixel A and pixel S, the pixels between pixel S and pixel M, the pixels between pixel M and pixel T, and the pixels between pixel T and pixel B until all pixels in the row have been screened.
[0082] Screening of pixels in the first column in the screening block: The processing process of pixels between pixel A and pixel C in the first column is similar to the screening process of pixels in the first row. First, the calculated value VM of the middle point pixel M is calculated based on the interpolation of pixel A and pixel C. The error between the comparison value VM and the true value PM of pixel M is compared to see whether it is within the maximum absolute error threshold e. If so, the middle point pixel M is not used as a candidate pixel; otherwise, pixel M is used as a candidate pixel; for the pixels between pixel A and pixel M, and between pixel M and pixel C, screening is performed in a similar manner as above until all pixels in the column are screened.
[0083] Screening of pixels in the sth column in the screening block: The processing process of pixels between pixel B and pixel D in the sth column is similar to the screening process of pixels in the first column until all pixels in the column are screened.
[0084] Screening of pixels in the 2nd to sth rows in the screening block: At this time, the pixel values in the 1st and sth columns of the 2nd to sth rows are determined, and the pixel screening is performed row by row using the method in step A above.
[0085] The steps of storing the candidate pixel label data and the candidate pixel value in the data file Xdata include:
[0086] Allocations 1 *s 2 The candidate pixel label data B[][] of the bit storage space; B[][] is a two-dimensional array with s 1 Lines 2 The columns correspond to whether each pixel in the screening block is a candidate pixel.
[0087] Mark the filtering status of each pixel in the filtering block from top to bottom and from left to right. If the pixel is a candidate pixel, set the marking data B[i][j] = 1, otherwise set the marking data B[i][j] = 0; if s 1 *s 2 The value of Ts is a multiple of 8, and is s*s / 8; if s 1 *s 2 If it is not a multiple of 8, that is, the tag data B[][] cannot be completely divided into an integer number of bytes, then the bits with the value of 0 are added at the end to make a complete byte, and the value of Ts is [s*s / 8]+1;
[0088] Write the candidate pixel label data B[][] in bytes, Ts bytes, into the data file Xdata; write the pixel values of the above-screened candidate pixels into the data file Xdata in order from top to bottom and from left to right; assuming there are m candidate pixels, each pixel value is double type, the Ts value increases by 8*m bytes.
[0089] In a specific embodiment, a certain screening block of continuous raster data s=7, the maximum absolute error threshold e=1.0, and the pixel values of the screening block are shown in Table 1 below:
[0090] Table 1
[0091] 562.3 563.1 568.7 564.6 564.8 565.7 566.3 662.3 663.1 663.7 664.6 674.8 655.7 666.3
[0092] When the screening block is dynamically screened, p[i][j] represents the pixel in the i-th row and j-th column of the screening block, and V[i][j] represents the pixel value in the i-th row and j-th column of the screening block;
[0093] For the first-row pixels, first, calculate the calculated value VM of the intermediate pixel p[1][4] according to the pixels p[1][1] and p[1][7] by interpolation, where VM = (V[1][1] + V[1][7]) / 2.0 = 564.3. Then, compare whether the error delt = 0.3 between the value VM and the true value PM = 564.6 of the pixel p[1][4] is within the maximum absolute error threshold e. Since delt < e, the intermediate pixel p[1][4] is not used as a candidate pixel for screening. Next, calculate the calculated value VM of the intermediate pixel p[1][2] according to the pixels p[1][1] and p[1][4] by interpolation, where VM = V[1][1] + (V[1][4] - V[1][1]) / 3 = 563.06. At this time, the pixel p[1][2] is not the middle position of the pixels p[1][1] and p[1][4]. Compare the error delt = 0.04 between the value VM and the true value PM = 563.1 of the pixel p[1][2]. Since delt < e, the intermediate pixel p[1][2] is not used as a candidate pixel for screening. Then, calculate the calculated value VM of the intermediate pixel p[1][3] according to the pixels p[1][2] and p[1][4] by interpolation, where VM = (V[1][2] + V[1][4]) / 2.0 = 563.85. Compare the error delt = 4.85 between the value VM and the true value PM = 568.7 of the pixel p[1][3]. Since delt > e, the intermediate pixel p[1][3] is used as a candidate pixel for screening. Similarly, perform interpolation screening on the remaining pixels. It can be known that there are 3 pixels in the first row as candidate pixels, namely p[1][1], p[1][3], and p[1][7]. Similarly, process the screening of all pixels in the first column and the seventh column, and then perform the screening of all pixels from the second row to the seventh row. It is obtained that there are 4 pixels in the seventh row as candidate pixels, namely p[7][1], p[7][5], p[7][6], and p[7][7]. Allocate candidate pixel marking data B[][] with 49 bit positions of storage space. The values of each flag bit are shown in Table 2 below:
[0094] Table 2
[0095] 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1
[0096] When writing the candidate pixel marking data B[][] into the data file Xdata in bytes, since 49 bit positions are not a multiple of 8 at this time, 7 bit positions with a value of 0 are added at the end to make a complete byte. A total of 7 bytes of storage space are required to obtain the following marking data, as shown in Table 3:
[0097] Table 3
[0098] 1 0 1 0 0 0 1 0 0 0 1 ... 1 1 1 0000000
[0099] For the 7-byte storage space in the above table, write them into the data file Xdata byte by byte from left to right; then write the pixel values of the candidate pixels screened above into the data file Xdata in order from top to bottom and from left to right, that is, write the values of pixels p[1][1], p[1][3] and p[1][7]; ..., p[7][1], p[7][5], p[7][6] and p[7][7] into the data file Xdata in sequence; assuming that there are m=12 candidate pixels, Ts=7+12*8=103 bytes; at this point, the dynamic screening process of the screening block is completed.
[0100] S3. Record the starting position of the filter block in the first column of each row in the data file Xdata to improve the efficiency of file reading and parsing.
[0101] It can be seen from the above steps that the storage space value used when dynamically filtering and writing data file Xdata for each filter block may not be the same. After storing all filter block data in data file Xdata in the order of the above steps, this will cause a problem: for example, where does the data of the filter block of row 2 and column 1 start in the data file Xdata, or from which byte in the data file Xdata does the data of the filter block of row 2 and column 1 begin. If the reading and parsing efficiency of filtering blocks one by one from the first row and column is low; if the data starting point position of the first column of each row of filter blocks is known, then the information of any filter block can be quickly read, and it is only necessary to parse the filter blocks from the first column of the row one by one to the filter block data of a certain column.
[0102] Therefore, it is also necessary to record the cumulative value sumTs of the storage space size Ts of each column filter block in each row and write it into the data file rowSize. For a row and b column filter blocks in S1, a integer values e1, e2, ..., ea can be accumulated by processing them row by row according to S2, where e1 means that the storage space of the filter blocks of all columns in the first row is e1 bytes, and ea means that the storage space of the filter blocks of all columns in the last row is ea bytes; these a integer values e1, e2, ..., ea are written into the data file rowSize.
[0103] S4. Record metadata information of the original continuous raster data Data.
[0104] The metadata information includes: the number of rows K and columns L of the original continuous raster data Data; the filter area s 1 、s 2 value, maximum absolute error threshold e parameter value, etc.; write the metadata information into the data file meta.
[0105] In this method, multi-level row and column pixel interpolation screening is first performed according to the specified four feature point pixel values. As long as the pixel values in a row or column are partially close, there will be a data compression effect. This method is independent of the initially specified four feature point pixel values and makes full use of the rule that "most pixel values outside the four feature point pixels also have local numerical similarities". It can be seen that this method has better data compression efficiency.
[0106] Based on the above-mentioned method for storing continuous raster data, the present invention also provides a method for reading continuous raster data. Specific reading process:
[0107] Assume that the pixel value of the rth row and cth column of the original continuous raster data Data is to be read; 1<=r<=K, 1<=c<=L;
[0108] Step 1. Read the data file meta, obtain the metadata information of the original continuous raster data Data, and obtain the number of rows K and columns L of the original continuous raster data Data; filter area s value, maximum absolute error threshold e parameter value, etc., and calculate according to S1 that there are a rows and b columns of filter blocks in the data file Xdata.
[0109] Step 2. Calculate the number of the filter block where the pixel in the rth row and cth column is located. Assume that the row number of the filter block where the requested pixel is located is v and the column number is z. According to the division method in S1, we can get:
[0110] When r / s 1 When it is an integer, v = r / s 1 ;
[0111] When r / s 1 When it is not an integer, v = [r / s 1 ]+1;
[0112] When c / s 2 When it is an integer, z=c / s 2 ;
[0113] When c / s 2 When it is not an integer, z=[c / s 2 ]+1.
[0114] In a specific embodiment, s 1 =s 2 =s; that is,
[0115] When r / s is an integer, v = r / s;
[0116] When r / s is not an integer, v=[r / s]+1;
[0117] When c / s is an integer, z = c / s;
[0118] When c / s is not an integer, z=[c / s]+1;
[0119] Step 3. Read the data file rowSize and obtain a integer values, e1, e2, ..., ea;
[0120] When v=1, the data of the first column of the first row of the filter block starts at byte 0 of the data file Xdata, and offset=0;
[0121] When v>1, the data of the first column of the filter block in the vth row starts at the e(v-1) byte of the data file Xdata, and offset=e(v-1);
[0122] The data file Xdata is read starting from the offset byte, that is, the filter block at the vth row and the first column is read and parsed one by one.
[0123] Specifically, if the current block being read is the jth column of the filter block, 1<=j<=z;
[0124] Step 3-1. Read candidate pixel label data.
[0125] If 1 *s 2 If it is a multiple of 8, read s from the data file Xdata 1 *s 2 / 8 bytes are candidate pixel label data; if s 1 *s 2 If it is not a multiple of 8, read [s 1 *s 2 / 8]+1 byte, take the first s 1 *s 2 The bit data is the candidate pixel label data.
[0126] In a specific embodiment, if s 1 =s 2 =s, if s*s is a multiple of 8, then read s*s / 8 bytes from the data file Xdata as the candidate pixel label data; if s*s is not a multiple of 8, then read [s*s / 8]+1 bytes from the data file Xdata; take the first s*s bits of data as the candidate pixel label data.
[0127] Step 3-2. Read candidate pixel value data.
[0128] Cumulative 1 *s 2The number of bits with a value of 1 in the bit candidate pixel mark data is m, and m double values v1, v2, v3, ..., vm are read from the data file Xdata, corresponding to s in the filter block respectively. 1 *s 2 There are m candidate pixel values.
[0129] In a specific embodiment, if s 1 =s 2 =s, accumulate the number of bits m with the value of 1 in the s*s bit candidate pixel mark data, read m double type values v1, v2, v3, ..., vm from the data file Xdata, which correspond to the s*s m candidate pixel values in the screening block respectively.
[0130] Step 3-3. Calculate the pixel value in the filter block where the requested pixel is located.
[0131] If j==z, then it is necessary to perform interpolation calculation based on the m candidate pixel values to obtain all pixel values in the screening block. The specific steps are as follows:
[0132] Before interpolating the middle pixel between two candidate pixels, determine whether the middle pixel value belongs to the candidate pixel. If it is a candidate pixel, there is no need to perform interpolation calculation, and directly determine the middle pixel value as the candidate pixel value. If not, the interpolation calculation result is used as the middle pixel value; performing interpolation processing row by row multiple times can obtain all pixel values in the filter block; then according to the row and column numbers r and c of the requested pixel, obtain the pixel position in the filter block, and then determine the pixel value, and the reading ends.
[0133] In a specific embodiment, before interpolating the intermediate pixel C between the pixels A and B, it is determined whether the pixel C value belongs to a candidate pixel. If it is a candidate pixel, no interpolation calculation is required, and the pixel C value is directly determined as the candidate pixel value. If not, the interpolation calculation result is used as the pixel C value. Multiple interpolation processes are performed row by row to obtain all pixel values in the filter block. Then, according to the column number r of the requested pixel, the pixel position in the filter block is obtained, and the pixel value is determined, and the reading ends.
[0134] In a specific embodiment, 7 bytes of storage space are read starting from the xxth byte in the data file Xdata to obtain the following candidate tag data of a certain screening block, as shown in Table 4:
[0135] Table 4
[0136] 1 0 1 0 0 0 1 0 0 0 1 ... 1 1 1 0000000
[0137] Take the first 49 bits of data as candidate pixel label data, and the number of bits with a value of 1 in the cumulative candidate pixel label data is 12. Then read 12 double type values v1, v2, v3, ..., v12 from the data file Xdata, which correspond to the 12 candidate pixel values of the screening block in Table 5 below:
[0138] Table 5
[0139] v1 0 v2 0 0 0 V3 0 0 0 V4 0 0 0 V9 0 0 0 V10 V11 V12
[0140] Interpolation is performed based on the values of these 12 candidate pixels to obtain the values of all pixels in the screening block. Before interpolation is performed on the intermediate pixel p[1][3] between pixels p[1][1] and p[1][7], it is determined whether the value of pixel p[1][3] belongs to the candidate pixel. Since pixel p[1][3] is not a candidate pixel, the value of pixel p[1][3] is determined by interpolation. Similarly, the value of pixel p[1][2] is determined by interpolating pixels p[1][1] and p[1][3]. Since pixel p[1][3] is a candidate pixel, interpolation does not need to be performed and is directly determined as the value v2. All pixel values can be determined in this way.
[0141] If j!=z, the requested pixel is not in the filter block, and there is no need to parse the pixel value in the filter block, and the next column of filter block data is processed.
[0142] Specific examples
[0143] Taking the national DEM (Digital Elevation Model) data as an example, at a resolution of 30 meters, the traditional storage method consists of 134724 rows and 161360 columns of raster pixel data, using 8-byte double-type numerical storage, and the total storage space required is approximately 161.9GB.
[0144] This method is applied to obtain M=8982, N=10758 divided screening blocks using a 15x15 pixel screening area. Then, the dynamic screening method is applied to these M*N screening blocks. The candidate pixel label data and candidate pixel values are stored in the data file Xdata under the condition of the maximum absolute error threshold e=3.0 meters. According to statistics, the storage size of the obtained data file Xdata is about 8.09GB, which is about 5% of the original data storage size; the data file rowSize storage space is 8982*8 bytes, approximately 70KB, and the metadata information storage space of the original DEM data can be ignored. Therefore, it can be seen that this method greatly saves storage space, and the data compression effect is significantly better than other existing methods.
[0145] The present invention provides a method for storing and reading continuous raster data, which has the following advantages:
[0146] This method makes full use of the rule that "most pixel values outside the four feature point pixels in the screening block also have local numerical similarities". It does not require that most pixel values in the screening block are the same or similar to the raster pixel values at a fixed position. It is applicable to continuous raster data with spatial similarity, such as DEM and slope data, and therefore has wider applicability and better data compression efficiency.
[0147] This method only involves simple interpolation calculations in the dynamic screening process and data file reading and parsing process of the screening block. It is simple to process and has high operation efficiency. It can save storage space and reduce system costs for the storage, backup and network transmission of massive raster data, and has obvious economic value. It is especially suitable for the display system of three-dimensional terrain data in large-scale real-time simulation (when the DEM data volume is large and the accuracy requirement is not high). It can have good data compression efficiency for DEM data and improve the response performance of the system.
[0148] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for storing continuous raster data. It is characterized in that Storing the original classified raster data Data consisting of K rows and L columns of pixels includes the following steps: S1. Re-divide the rows and columns of the original classified raster data Data: The rows and columns of the original raster data Data composed of K rows and L columns of pixels are re-divided with the screening area as the minimum granularity to obtain a rows and b columns of screening blocks; When K / s 1 When a is an integer, a=K / s 1 ; When K / s 1 When it is not an integer, a=[K / s 1 ]+1; When L / s 2 When b is an integer, b=L / s 2 ; When L / s 2 When it is not an integer, b=[L / s 2 ]+1; Among them, the screening area is s 1 Lines 2 The raster data matrix of columns, s 1 、s 2 is a constant, s 1 >=3,s 2 >=3; S2. For a row and b column screening blocks, the error control method is used to dynamically screen the pixels in each screening block, and the candidate pixel label data and candidate pixel values are stored in the data file Xdata; S3. Record the starting position of the filter block in the first column of each row in the data file Xdata; S4. Record metadata information of the original continuous raster data Data; In S2, for the screening blocks with a rows and b columns, error control is used to perform dynamic pixel screening on the screening blocks one by one, specifically including the following steps: selecting multiple feature points as candidate pixels in the screening blocks with a rows and b columns; determining the maximum absolute error threshold e parameter value; interpolating and calculating layer by layer according to the candidate pixels using the maximum absolute error threshold e parameter value, so as to perform dynamic pixel screening; The dynamic pixel screening specifically includes the following steps: selecting the middle pixel between the candidate pixels, calculating the calculated value of the middle point pixel, judging whether the error between the calculated value of the middle pixel and its true value is within the maximum error threshold e, if so, the middle pixel is not used as a screening candidate pixel, otherwise the middle pixel is used as a candidate pixel; screening is performed row by row and column by column until all pixels are screened.
2. A method for storing continuous raster data according to claim 1, It is characterized in that In the step S2, the candidate pixel label data and the candidate pixel value are stored in the data file Xdata; The value Ts is used to record the byte size required for storing the current filter block, which is initially 0; Mark the screening status of each pixel row by row and column by column in the screening block. If the pixel is a candidate pixel, set the marking data B[i][j]=1, otherwise set the marking data B[i][j]=0; like The Ts value is a multiple of 8. ;like If it is not a multiple of 8, that is, the tag data B[][] cannot be completely divided into an integer number of bytes, then a bit with a value of 0 is added at the end to complete a byte, and the value of Ts is ; The candidate pixel label data B[][] is written into the data file Xdata in bytes of Ts bytes; the pixel values of the candidate pixels screened above are written into the data file Xdata in sequence.
3. A method for storing continuous raster data according to claim 2, It is characterized in that The step S3 records the storage starting position of the filter block of the first column of each row in the data file Xdata, including the following steps: recording the cumulative value sumTs of the storage space size Ts of the filter blocks of each column in each row, and writing it into the data file rowSize.
4. A method for storing continuous raster data according to claim 2, It is characterized in that In step S4, the metadata information includes: the number of rows K and the number of columns L of the original continuous raster data Data; the screening area s 1 、s 2 Value, maximum absolute error threshold e parameter value.
5. A method for reading continuous raster data, for reading raster data stored according to a method for storing continuous raster data according to any one of claims 1 to 4, It is characterized in that To read the grid cell data D(r, c) of the pixel value of the rth row and cth column of the original classified grid data Data, where 1<=r<=K and 1<=c<=L, the following steps are included: Step 1. Read the data file meta, obtain the metadata information of the original continuous raster data Data, and obtain the number of rows K and columns L of the original continuous raster data Data; filter area s 1 、s 2 value, the maximum absolute error threshold e parameter value, calculate that there are a rows and b columns of screening blocks in the data file Xdata; Step 2. Calculate the number of the filter block where the pixel at the rth row and the cth column is located. Assume that the row number of the filter block where the requested pixel is located is v and the column number is z; When r / s 1 When it is an integer, v = r / s 1 ; When r / s 1 When it is not an integer, v = [r / s 1 ]+1; When c / s 2 When is an integer, z = c / s 2 ; When c / s 2 When it is not an integer, z = [c / s 2 ]+1; Step 3. Read the data file rowSize and obtain a integer values, e1, e2, ..., ea; When v=1, the data of the first column of the first row of the filter block starts at byte 0 of the data file Xdata, and offset=0; When v>1, the data of the first column of the filter block in row v starts at the e(v-1) byte of the data file Xdata, and offset=e(v-1); The data file Xdata is read starting from the offset byte, and the information of the filter blocks is parsed one by one, so as to calculate the pixel value in the filter block where the requested pixel is located.
6. A method for reading continuous raster data according to claim 5, It is characterized in that Regarding step 3 of parsing the information of the filter blocks one by one, the parsing of the information of the filter blocks includes reading candidate pixel label data and reading candidate pixel value data.
7. A method for reading continuous raster data according to claim 6, It is characterized in that Parsing the information of the filter block to calculate the pixel value in the filter block where the requested pixel is located specifically includes the following steps: If the current block being read is the jth column of the filter block, 1<=j<=z; Read candidate pixel label data: like If it is a multiple of 8, it is read from the data file Xdata. bytes are candidate pixel label data; if If it is not a multiple of 8, read it from the data file Xdata Bytes, take the first The bit data is the candidate pixel label data; Read candidate pixel value data: Grand total The number of bits m with a value of 1 in the bit candidate pixel mark data is read from the data file Xdata as m double type values v1, v2, v3, ..., vm, which correspond to the bits in the filter block respectively. m candidate pixel values; If j==z, then interpolation is performed based on the m candidate pixel values to obtain all pixel values in the filter block; If j!=z, the requested pixel is not in the filter block, and there is no need to parse the pixel value in the filter block, and continue to process the next column of filter block data.
8. A method for reading continuous raster data according to claim 7, It is characterized in that The interpolation calculation to obtain all pixel values in the filter block includes the following steps: Before interpolating the middle pixel between two candidate pixels, determine whether the middle pixel value belongs to the candidate pixel. If it is a candidate pixel, no interpolation calculation is required, and the middle pixel value is directly determined to be the candidate pixel value. If not, the interpolation calculation result is used as the middle pixel value. Perform interpolation processing multiple times row by row to obtain all pixel values in the screening block. Then, according to the row and column numbers r and c of the requested pixel, the pixel position in the filter block is obtained, and then the pixel value is determined, and the reading is completed.
Citation Information
Patent Citations
Multi-source data fusion method based on spatio-temporal dynamic triple matching analysis
CN114004303A
Method and system for converting an image
US20110229040A1