A method for lossless compression storage and reading of classified raster data

By storing block division and classification information statistics on the sub-type raster data, dynamically managing classified labeled data, solving the problems of waste of storage space and data redundancy in the existing technology, and achieving efficient data storage and reading.

CN115543944BActive Publication Date: 2025-03-04LUDONG UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211159391.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2025-03-04
Estimated Expiration
2042-09-22

AI Technical Summary

Technical Problem

In the prior art, when storing and reading subtype raster data, there are problems of waste of storage space and data redundancy, especially when there are many types of classification, resulting in high storage costs and low network transmission efficiency.

Method used

By dividing the original classification raster data into multiple storage blocks, and performing classification information statistics and label data compression for each storage block, dynamically decide whether to record the classification tag data to reduce redundant storage.

Benefits of technology

It effectively reduces the amount of data storage, saves storage equipment costs, improves network transmission efficiency, optimizes the redundancy problem of classified labeled data, and improves the data compression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543944B_ABST
    Figure CN115543944B_ABST
Patent Text Reader

Abstract

The present invention discloses a lossless compression storage and reading method for classified raster data. The storage method re-divides the rows and columns of the original classified raster data Data composed of K rows and L columns of pixels with a unit storage area as the minimum granularity to obtain a row and b column storage blocks; for the a row and b column storage blocks, the classification information of each storage block is counted row by row and column by column, the classification information is stored in a data file Xdata, the storage space size of the classification information of the storage block is recorded and stored in the data file rowSize; the metadata information of the original classified raster data Data is stored, and the metadata information is stored in the data file meta. The method avoids the situation that the storage of the label data of the classification value may not be worth the loss when there are many types of classified raster data through conditional judgment, optimizes the data redundancy problem of the classified label data, and improves the data compression efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of raster data processing, and in particular to a method for lossless compression storage and reading of classified 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. The position of each pixel is determined by the row and column number, and the value of the pixel is used to record a certain type of geographic attribute value at this position. Raster data with integer pixel values ​​are usually used to store various so-called discrete data or classified data. This data set describes a class of objects whose geographic attribute values ​​at the location of the raster pixel are integers. For example, in the land use type raster data, each pixel stores an integer, which represents 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.

[0003] Assume that a certain type of raster data is composed of K rows and L columns of raster pixels, and the value corresponding to each raster pixel is a one-byte unsigned integer value. For example, each raster pixel of the above land use type raster data stores the integer value of the land use classification. According to the common practice of the current raster data model, each raster pixel is stored with 1 byte, which requires K*L bytes. When the coverage area of ​​the type of raster data is large and the accuracy is high, the number of rows and columns of the raster K*L is large, and the required storage space is very large, which is a great challenge to the system's storage device cost and network transmission efficiency.

[0004] Although there are some optimized storage methods for classified raster data at present, there are various application conditions. For example, in the Chinese invention patent "A storage method and device containing local valid raster data" with publication number CN103886045B, it is required that when the number of invalid raster pixels in the raster data is large, the storage space can be reduced. When the number of invalid raster pixels is 0, they are all valid raster pixel data, that is, the classified raster data of this application, and the storage space cannot be reduced; if the label data of each classification value is stored according to the method in the article, there are two problems: first, the label data redundancy of each classification value is large; second, when the number of classifications is large, for example, more than 100 classification values, the required label data is very large, which may exceed the amount of original raster data and require more storage space.

[0005] In addition, in the Chinese invention patent "A method for storing and reading classified raster data" with publication number CN107977427B, it is required that when the first largest classification pixel of the classified raster data accounts for a large proportion, better compression efficiency can be achieved; there are also some lossy compression methods that will lose data accuracy in exchange for reducing storage space, while the method of the present application has a wider range of application conditions, does not require strict restrictions, and is a lossless compression processing method with higher compression efficiency. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a lossless compression storage and reading method for classified raster data, which can effectively reduce the amount of data storage, save storage device costs and improve network transmission efficiency.

[0007] The technical solution of the present invention to solve the above technical problems is as follows:

[0008] A lossless compression storage method for classified raster data stores original classified raster data Data consisting of K rows and L columns of m types of pixels, including the following steps:

[0009] S1. Re-dividing the rows and columns of the original classified raster data Data composed of K rows and L columns of pixels with the unit storage area as the minimum granularity to obtain a row and b column storage blocks;

[0010] When K / s1 is an integer, a=K / s1;

[0011] When K / s1 is not an integer, a=[K / s1]+1;

[0012] When L / s2 is an integer, b = L / s2;

[0013] When L / s2 is not an integer, b=[L / s2]+1;

[0014] Among them, the unit storage area is a grid data matrix with s1 rows and s2 columns;

[0015] S2. For a row and b column storage blocks, count the classification information of each storage block row by row and column by column, and store the classification information in the data file Xdata, wherein the classification information includes: the total number of storage block classification tags, each classification value, and classification tag data; record the storage space size of the storage block classification information, and store it in the data file rowSize;

[0016] S3. Storing metadata information of the original classified raster data Data, and storing the metadata information in a data file meta.

[0017] Furthermore, in step 2, the total number of classification marks of the storage blocks, the classification values, and the classification mark data are counted, including the following steps:

[0018] Arrange all pixel classification values ​​in the storage block in order from most to least according to the total number of pixels to obtain n integer values ​​of d1, d2, ..., dn, that is, n classification pixel values; for these n classification pixel values, determine in order whether the pixels of the classification need to record classification mark data;

[0019] For judging whether a pixel with a classification value of dj, where 1<=j<=n, needs to record classification mark data, it is determined by comparison: if the storage space used to record the classification mark data is less than the number of pixels of this classification in the storage block*8, then the classification mark data needs to be recorded; if the storage space used to record the classification mark data is greater than the number of pixels of this classification in the storage block*8, then the classification mark data does not need to be recorded;

[0020] In this way, the total number of classification marks t that need to be recorded and the classification values ​​v1, v2, ..., vt that need to be recorded are obtained.

[0021] Furthermore, recording the storage space size used for the classified label data includes the following steps:

[0022] The classification label data B[][] is a two-dimensional array whose size is not fixed;

[0023] For the classification mark data B[][] with the largest number of pixels and the classification value of d1, it is s1 rows and s2 columns, and the storage space used is s1*s2 bits, which indicates whether a certain pixel in the storage block is a pixel with the classification value of d1; if B[g][h]=0, it means that the pixel in the gth row and hth column in the storage block is not a pixel with the classification value of d1, 1<=g<=s1; 1<=h<=s2; if B[g][h]=1, it means that the pixel in the gth row and hth column in the storage block is a pixel with the classification value of d1, assuming that there are m1 pixels with the classification value of d1 in the storage block;

[0024] The storage space used for the classification label data B[][] with the classification value d2, which has the second largest number of pixels, is s1*s2-m1 bits, assuming that there are m2 pixels with the classification value d2 in the storage block; similarly, the storage space used for the classification label data B[][] with the classification value d3, which has the second largest number of pixels, is s1*s2-m1-m2 bits;

[0025] By analogy, the storage space size used for pixel classification label data of all classification values ​​is determined.

[0026] Furthermore, the step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, including the following steps:

[0027] The value Ts is used to record the byte size required to store the classification information of the current storage block, which is initially 0; if the total number of classification tags t that needs to be recorded is stored using an x-byte integer, the Ts value increases by x; if each classification value v1, v2, ..., vt is stored using a 1-byte integer respectively, the Ts value increases by t.

[0028] Furthermore, the step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, including the following steps:

[0029] The labeled data B[][] of category i (1<=i<=t) requires ki bits of storage space. If there are t categories of labeled data to be stored in the storage block, then T=k1+k2+...+kt bits of storage space are required;

[0030] If T is a multiple of 8, the T / 8 byte integer value is stored in bytes, and the Ts value increases by T / 8.

[0031] If T is not a multiple of 8, you need to add 0 bits at the end to [T / 8]+1 bytes, store this [T / 8]+1 byte integer value, and increase the Ts value by [T / 8]+1.

[0032] Furthermore, the step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, including the following steps:

[0033] The pixels in the storage block whose pixel values ​​are not the classification values ​​v1 or v2, ..., or vt are arranged in row and column order to store the pixel values. Assuming there are w pixel values, the Ts value increases by w.

[0034] Furthermore, the cumulative value sumTs of the storage space size Ts of each column storage block in each row is recorded and written into the data file rowSize.

[0035] Furthermore, the metadata information includes the number of rows K and the number of columns L of the original classified raster data Data; the values ​​of the storage areas s1 and s2; and the metadata information is written into the data file meta.

[0036] A lossless compression reading method for classified raster data is used to read the raster data stored according to the above-mentioned lossless compression method for classified 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:

[0037] Step 1. Read the data file meta, obtain the metadata information of the original classified raster data Data, obtain the number of rows K and columns L of the original classified raster data Data; the values ​​of storage areas s1 and s2, etc., and calculate that there are a rows and b columns of storage blocks in the data file Xdata;

[0038] Step 2. Calculate the number of the storage block where the pixel in the rth row and cth column is located. Assuming that the row number of the storage block where the requested pixel is located is v and the column number is z, we can get:

[0039] When r / s1 is an integer, v=r / s1;

[0040] When r / s1 is not an integer, v=[r / s1]+1;

[0041] When c / s2 is an integer, z = c / s2;

[0042] When c / s2 is not an integer, z=[c / s2]+1;

[0043] Step 3. Read the data file rowSize and obtain a integer values, e1, e2, ..., ea; wherein e1 indicates that the total classification information storage space of the storage blocks of all columns in the first row is e1 bits, and ea indicates that the total classification information storage space of the storage blocks of all columns in the last row is ea bits;

[0044] When v=1, the data of the first column storage block of the first row starts at byte 0 of the data file Xdata, and the reading point position offset=0;

[0045] When v>1, the data of the first column of the storage block in the vth row starts at the e(v-1) byte of the data file Xdata, and the reading point position offset=e(v-1);

[0046] The data file Xdata is read starting from the offset byte, that is, the storage block at the vth row and the first column is read and parsed, and the information of the storage blocks is parsed one by one.

[0047] Furthermore, the step 3 specifically includes the following steps: assuming that the jth storage block is currently being read, 1<=j<=z;

[0048] Step 3.1 read the total number of classification marks t and the classification values ​​v1, v2, ..., vt that need to be recorded;

[0049] Read x bytes from the data file Xdata as the total number of classification tags t;

[0050] If t>0, read nt bytes from the data file Xdata continuously to obtain the classification values ​​v1, v2, ..., vt;

[0051] If t is 0, execute step 3.3 to read a series of pixel values ​​of other categories arranged in row and column order;

[0052] Step 3.2 reads the classification mark data to be recorded;

[0053] Read s1*s2 bits of data from the data file Xdata as the classified pixel label data B1[][] of the classified value v1, and accumulate the number of bits with a value of 1 in the classified pixel label data, assuming it is m1, allocate an integer value matrix D[][] with s1 rows and s2 columns, and set the position marked as 1 in the classified pixel label data B1[][] to v1 in the matrix D[][]. Read s1*s2-m1 bits of data from the data file Xdata as the classified pixel label data B2[][] of the classified value v2, and accumulate the number of bits with a value of 1 in the classified pixel label data, assuming it is m2, and correspond the elements in the matrix D[][] whose values ​​are not v1 to the s1*s2-m1 bits in the pixel label data B2[][] in row and column order;

[0054] Set the position marked as 1 in B2[][] to v2 in the matrix D[][]. Similarly, by reading the label data of each classified pixel, the values ​​of each type of pixel in the storage area where the classified label data needs to be stored can be obtained.

[0055] Accumulate the number of bits with a value of 1 in each classification label data, assuming there are y = m1 + m2 + ... + mt;

[0056] Step 3.3 reads a series of pixel values ​​of other categories arranged in row and column order;

[0057] Read s1*s2-y 1-byte integer values ​​from the data file Xdata to obtain a series of pixel values ​​of other categories arranged in row and column order;

[0058] If j == z, then calculate the pixel position of the requested pixel in the storage block, obtain the pixel value, and the reading ends;

[0059] If j!=z, the requested pixel is not in the storage block, and the next column of storage block data is parsed and processed according to this step.

[0060] Compared with the prior art, the present invention has the following technical effects:

[0061] This method avoids the situation where storing labeled data of classification values ​​may not be worth the cost when there are many types of classified raster data through conditional judgment; in addition, this method also optimizes the data redundancy problem of classified labeled data and improves data compression efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 It is a schematic diagram of the overall structure of the system of the present invention. DETAILED DESCRIPTION

[0063] 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.

[0064] Reference Figure 1 A lossless compression storage method for classified raster data is provided. The original classified raster data Data composed of K rows and L columns of pixels is stored. There are m non-repeating integer values ​​corresponding to all pixels, that is, the pixels of the original classified raster data Data have m different attribute categories. Assume that the integer value of the first type of pixel is p1, the integer value of the second type of pixel is p2, ..., and the integer value of the mth type of pixel is pm. For the convenience of description, the row and column numbers of the pixels and blocks of the original classified raster data Data are counted from 1. In the present invention, the symbol [x] represents the maximum integer not greater than x.

[0065] The lossless compression storage method of classified raster data specifically includes the following steps:

[0066] S1. Re-dividing the rows and columns of the original classified raster data Data composed of K rows and L columns of pixels with the unit storage area as the minimum granularity to obtain a row and b column storage blocks;

[0067] When K / s1 is an integer, a=K / s1;

[0068] When K / s1 is not an integer, a=[K / s1]+1;

[0069] When L / s2 is an integer, b = L / s2;

[0070] When L / s2 is not an integer, b=[L / s2]+1;

[0071] The unit storage area is a grid data matrix with s1 rows and s2 columns.

[0072] In a specific embodiment, the number of pixel rows s1 and the number of columns s2 in the unit storage area may be unequal or equal. If s1=s2=s, the unit storage area is composed of s rows and s columns of pixels, and the original classified raster data Data is divided from top to bottom and from left to right with the unit storage area as the minimum granularity to obtain a row and b column storage blocks, that is:

[0073] When K / s is an integer, a=K / s;

[0074] When K / s is not an integer, a=[K / s]+1, at this time, there are s rows of pixels in the storage blocks from the first row to the a-1th row, and there are (K-[K / s]*s) rows of pixels in the storage block of the ath row;

[0075] When L / s is an integer, b = L / s;

[0076] When L / s is not an integer, b=[L / s]+1, and there are s columns of pixels in the storage blocks from the first column to the b-1th column, and there are (L-[L / s]*s) columns of pixels in the storage block of the bth column.

[0077] That is to say, when the original classified raster data Data cannot be completely divided by the unit storage area, the actual number of pixels in the storage block of the rightmost column or the bottom row is not equal to s*s.

[0078] That is, the number of pixels in the storage block includes two cases: the storage block contains s1*s2 pixels and the storage block contains less than s1*s2 pixels.

[0079] S2. For a rows and b columns of storage blocks, count the classification information of each storage block row by row and column by column, and store the classification information in the data file Xdata. The classification information includes: the total number of storage block classification marks t, each classification value, and classification mark data; record the storage space size of the storage block classification information and store it in the data file rowSize.

[0080] S2 counts the total number of block classification marks, each classification value, and classification mark data, and specifically includes the following steps:

[0081] Arrange all pixel classification values ​​in the storage block in order from most to least according to the total number of pixels to obtain n integer values ​​of d1, d2, ..., dn, that is, n classification pixel values; for these n classification pixel values, determine in order whether the pixels of the classification need to record classification mark data;

[0082] For judging whether a pixel with a classification value of dj, where 1<=j<=n, needs to record classification mark data, it is determined by comparison: if the storage space used to record the classification mark data is less than the number of pixels of this classification in the storage block*8, then the classification mark data needs to be recorded; if the storage space used to record the classification mark data is greater than the number of pixels of this classification in the storage block*8, then the classification mark data does not need to be recorded;

[0083] In this way, the total number of classification marks t that need to be recorded and the classification values ​​v1, v2, ..., vt that need to be recorded are obtained.

[0084] The size of the storage space used for recording the classification mark data includes the following steps:

[0085] The classification label data B[][] is a two-dimensional array whose size is not fixed;

[0086] For the classification mark data B[][] with the largest number of pixels and the classification value of d1, it is s1 rows and s2 columns, and the storage space used is s1*s2 bits, which indicates whether a certain pixel in the storage block is a pixel with the classification value of d1; if B[g][h]=0, it means that the pixel in the g-th row and h-th column in the storage block is not a pixel with the classification value of d1, 1<=g<=s1; 1<=h<=s2; if B[g][h]=1, it means that the pixel in the g-th row and h-th column in the storage block is a pixel with the classification value of d1, assuming that there are m1 pixels with the classification value of d1 in the storage block.

[0087] The storage space used for the classification mark data B[][] with the classification value d2, which has the second largest number of pixels, is s1*s2-m1 bits. Because for the s1*s2 pixels in the storage block, since the classification mark data B[][] with the classification value d1 has already marked m1 pixel positions with the classification value d1, at this time, the pixels with the classification value d1 in the s1*s2 pixels in the storage block are removed, and the remaining s1*s2-m1 pixels are marked to see whether they are pixels with the classification value d2. Therefore, only s1*s2-m1 bits of storage space are needed, assuming that there are m2 pixels with the classification value d2 in the storage block. Similarly, the storage space used for the classification mark data B[][] with the classification value d3, which has the second largest number of pixels, is s1*s2-m1-m2 bits; and so on, the storage space size used for the classification mark data of pixels of all classification values ​​is determined. And so on, the storage space size used for the classification mark data of pixels of all classification values ​​is determined.

[0088] In a specific embodiment, if s1=s2=s, that is, the unit storage area is composed of s rows and s columns of pixels. For the classification mark data B[][] with the largest number of pixels and the classification value of d1, it is s rows and s columns, and the storage space used is s*s bits, which indicates whether a certain pixel in the storage block is a pixel with the classification value of d1; if B[g][h]=0, it means that the pixel in the gth row and hth column in the storage block is not a pixel with the classification value of d1, 1<=g<=s; 1<=h<=s; if B[g][h]=1, it means that the pixel in the gth row and hth column in the storage block is a pixel with the classification value of d1, assuming that there are m1 pixels with the classification value of d1 in the storage block. The storage space used for the classification mark data B[][] with the classification value d2, which has the second largest number of pixels, is s*s-m1 bits. Because for the s*s pixels in the storage block, since the classification mark data B[][] with the classification value d1 has already marked m1 pixel positions with the classification value d1, at this time, the pixels with the classification value d1 in the s*s pixels in the storage block are removed, and the remaining s*s-m1 pixels are marked to see whether they are pixels with the classification value d2. Therefore, only s*s-m1 bits of storage space are needed, assuming that there are m2 pixels with the classification value d2 in the storage block. Similarly, the storage space used for the classification mark data B[][] with the classification value d3, which has the second largest number of pixels, is s*s-m1-m2 bits; and so on, it is determined whether the pixels of all classification values ​​need to record the classification mark data.

[0089] The size of the classification label data B[][] gradually decreases in the order of the classification value dj in order to reduce the redundancy between different classification label data, which can greatly reduce the data storage space, especially when the pixels with the most classification values ​​account for a large proportion in the storage block.

[0090] The value Ts is used to record the byte size required for storing the classification information of the current storage block, which is initially 0; that is, the total number of required classification marks, each classification value, and classification mark data are stored.

[0091] If the total number of classification tags t that needs to be recorded is stored using an x-byte integer, then the Ts value increases by x. For example, if the total number of classification tags t that needs to be recorded is stored using a 1-byte integer, then the Ts value increases by 1. If it is stored using a 2-byte integer, then the Ts value increases by 2. And so on. If it is stored using an x-byte integer, then the Ts value increases by x.

[0092] Each classification value v1, v2, ..., vt is stored as a 1-byte integer, and the Ts value increases by t.

[0093] Category i (1<=i<=t) mark data B[][] requires ki bits of storage space. Assuming that there are t categories of mark data that need to be stored in the storage block, a total of T=k1+k2+...+kt bits of storage space are required; if T is a multiple of 8, then the T / 8 byte integer value is stored in bytes, and the Ts value increases by T / 8; if T is not a multiple of 8, it is necessary to add bits of 0 to the end to [T / 8]+1 bytes, store the [T / 8]+1 byte integer value, and increase the Ts value by [T / 8]+1.

[0094] It is necessary to store a series of other classified pixel values ​​arranged in row and column order in the storage block; the pixels in the storage block whose pixel values ​​are not classified values ​​v1 or v2, ... or vt are arranged in row and column order to store the pixel values. Assuming there are w pixel values, the Ts value increases by w.

[0095] In a specific embodiment, if s=4, the pixel classification value of a certain storage block is as shown in Table 1 below.

[0096] Table 1

[0097] 1 2 3 3 2 2 1 1 3 4 5 2 1 2 1 2

[0098] First, all pixel classification values ​​in the storage block are arranged in descending order according to the total number of pixels, and n=5 integer classification values ​​of d1=2, d2=1, d3=3, d4=4, and d5=5 are obtained.

[0099] Secondly, for these n=5 classified pixel values, determine in order whether the classified pixels need to record classification label data.

[0100] For example, whether it is necessary to record classification mark data for the pixel with classification value d1=2 in the storage block is determined by comparison: the storage space used to record the classification mark data is 16 bits, and the number of pixels with classification value d1 in the storage block is 6. If these pixel values ​​are stored separately, 48 bits are required. Therefore, recording the classification mark data can compress the data, so it is necessary to record the classification value d1 mark data; then, it is determined whether it is necessary to record the classification mark data for the pixel with classification value d2=1 in the storage block. Since the storage space used to record the classification mark data is 16-6=10 bits, the number of pixels with classification value d2 in the storage block is 5. If these pixel values ​​are stored separately, 40 bits are required. Therefore, it is necessary to record the classification value d2 mark data; again, whether it is necessary to record the classification mark data for the pixel with classification value d3=3 in the storage block, since the storage space used to record the classification mark data is 1 6-6-5=5 bits, the number of pixels with classification value d3 in the storage block is 3. If these pixel values ​​are stored separately, 24 bits are required, so it is necessary to record the classification value d3 mark data; again, whether the pixels with classification value d4=4 in the storage block need to record the classification mark data, because the storage space used to record the classification mark data is 16-6-5-3=2 bits, the number of pixels with classification value d4 in the storage block is 1, and if these pixel values ​​are stored separately, 8 bits are required, so it is necessary to record the classification value d4 mark data; finally, whether the pixels with classification value d5=5 in the storage block need to record the classification mark data, because the storage space used to record the classification mark data is 16-6-5-3-1=1 bit, the number of pixels with classification value d5 in the storage block is 1, and if these pixel values ​​are stored separately, 8 bits are required, so it is necessary to record the classification value d5 mark data.

[0101] At this point, we can get the total number of classification tags that need to be recorded t=5 and the classification values ​​d1, d2, d3, d4, d5 that need to be recorded; the total number of classification tags t that needs to be recorded is assumed to be stored as a 1-byte integer, then the Ts value increases by 1; each classification value d1, d2, d3, d4, d5 is stored as a 1-byte integer respectively, then the Ts value increases by 5.

[0102] The classification value d1 tag data B[][] requires 16 bits, and the corresponding bit values ​​are shown in Table 2 below:

[0103] Table 2

[0104] 0 1 0 0 1 1 0 0 0 0 0 1 0 1 0 1

[0105] Arrange them in row order, and get the 16 bit values ​​as shown in Table 3:

[0106] Table 3

[0107] 0 1 0 0 1 1 0 0 0 0 0 1 0 1 0 1

[0108] At this time, the pixels with classification value d1 in the storage block are removed, and the remaining 10 pixel values ​​are as shown in Table 4:

[0109] Table 4

[0110]

[0111]

[0112] Set the pixel mark of the classification value d2 from top to bottom and from left to right, and obtain the classification value d2 mark data with 10 bits as shown in Table 5:

[0113] Table 5

[0114]

[0115] Similarly, at this time, the pixels with classification value d2 in the storage block are removed, and the remaining 5 pixel values ​​are as shown in Table 6:

[0116] Table 6

[0117] 3 3 3 4 5

[0118] Set the pixel mark of the classification value d3 from top to bottom and from left to right, and obtain the classification value d3 mark data with 5 bits as shown in Table 7:

[0119] Table 7

[0120]

[0121] Similarly, the pixels with classification value d3 in the storage block are removed, and the remaining 2 pixel values ​​are as shown in Table 8:

[0122] Table 8

[0123]

[0124]

[0125] The classification d4 tag data is obtained as 2-bit values ​​as shown in Table 9:

[0126] Table 9

[0127]

[0128] Finally, the pixel with the classification value of d4 in the storage block is removed, and the remaining pixel value is as shown below. Although the classification value d5 can be analyzed through the above 4 classification values, for the simplicity and consistency of the description of this method, the same processing is continued, as shown in Table 10:

[0129] Table 10

[0130] 5

[0131] The classification d5 tag data is obtained as 1 bit value as shown in Table 11:

[0132] Table 11

[0133]

[0134] There are t=5 categories of labeled data that need to be stored in this storage block, and a total of (16+10+5+2+1)=34 bits of storage space are required. Since it is not a multiple of 8, 6 bits of 0 are added at the end, and the 5-byte integer value is stored in bytes, and the Ts value increases by 5.

[0135] Finally, it is necessary to store a series of other classified pixel values ​​arranged in row and column order in the storage block; in this example, all pixel values ​​in the storage block need to store classified label data, and there are no other classified pixel values, so no processing is required; at this point, the classified data of the storage block is stored, and a total of Ts = 11 bytes are required. Compared with the usual method that requires 16 bytes, this method saves 31% of storage space. Of course, this is when there are 5 classifications in the 16 pixels. If there are 1 or 2 classifications in the 16 pixels, this method can achieve better compression effect.

[0136] It can be seen from the above steps that the storage space value used when dynamically filtering and writing each storage block into the data file Xdata may not be the same. After storing all the storage block classification data into the data file Xdata in the order of the above steps, the efficiency of reading and parsing the storage blocks one by one from the first row and the first column is low. In order to improve the efficiency of subsequently reading the storage block classification information of any row and column number from the data file, it is necessary to record the total storage space size value required to store all the storage block classification information in each row.

[0137] Therefore, during the processing of the previous step, it is also necessary to record the cumulative value sumTs of the storage space size Ts of each column storage block in each row and write it into the data file rowSize. For a row and b column storage blocks in S1, we can accumulate a integer values ​​e1, e2, ..., ea by processing them row by row according to S2, where e1 means that the storage space of the storage blocks of all columns in the first row is e1 bytes, and ea means that the storage space of the storage blocks of all columns in the last row is ea bytes; write these a integer values ​​e1, e2, ..., ea into the data file rowSize.

[0138] S3. Storing metadata information of the original classified raster data Data, and storing the metadata information in a data file meta.

[0139] The metadata information includes the number of rows K and the number of columns L of the original classified raster data Data; the values ​​of storage areas s1 and s2, etc.; and the metadata information is written into the data file meta.

[0140] Based on the above-mentioned lossless compression storage method for classified raster data, the present invention also provides a lossless compression reading method for classified raster data. Specific reading process:

[0141] 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, 1<=c<=L, the following steps are included:

[0142] Step 1. Read the data file meta, obtain the metadata information of the original classified raster data Data, obtain the number of rows K and columns L of the original classified raster data Data; the values ​​of storage areas s1 and s2, etc., and calculate that there are a rows and b columns of storage blocks in the data file Xdata.

[0143] Step 2. Calculate the number of the storage block where the pixel in the rth row and cth column is located. Assuming that the row number of the storage block where the requested pixel is located is v and the column number is z, we can get:

[0144] When r / s1 is an integer, v=r / s1;

[0145] When r / s1 is not an integer, v=[r / s1]+1;

[0146] When c / s2 is an integer, z = c / s2;

[0147] When c / s2 is not an integer, z=[c / s2]+1.

[0148] Step 3. Read the data file rowSize and obtain a integer value, e1, e2, ..., ea; where e1 indicates that the total classification information storage space of the storage block of all columns in the first row is e1 bits, and e a It indicates that the total classification information storage space of the storage blocks of all columns in the last row is ea bits.

[0149] When v=1, the data of the first column storage block of the first row starts at byte 0 of the data file Xdata, and the reading point position offset=0;

[0150] When v>1, the data of the first column of the storage block in the vth row starts at the e(v-1) byte of the data file Xdata, and the reading point position offset=e(v-1);

[0151] The data file Xdata is read starting from the offset byte, that is, the storage block at the vth row and the first column is read and parsed, and the information of the storage blocks is parsed one by one.

[0152] Specifically, assuming that the jth storage block is currently being read, 1<=j<=z; the total number of classification tags t that need to be recorded and the classification values ​​v1, v2, ..., vt that need to be recorded are read.

[0153] Step 3.1 read x bytes from the data file Xdata as the total number of classification tags t;

[0154] If t>0, read t bytes from the data file Xdata continuously to obtain the classification values ​​v1, v2, ..., vt;

[0155] If t is 0, execute step 3.3 to read a series of pixel values ​​of other categories arranged in row and column order, and y=0 at this time.

[0156] Step 3.2 reads the classification mark data to be recorded;

[0157] First, s1*s2 bits of data are read from the data file Xdata as the classified pixel label data B1[][] of the classified value v1, and the number of bits with a value of 1 in the classified pixel label data is accumulated, assuming it is m1, and an integer value matrix D[][] with s1 rows and s2 columns is allocated (assuming the initial assignment is 0), and the positions marked as 1 in the classified pixel label data B1[][] are set to value v1 in the matrix D[][]. s1*s2-m1 bits of data are read from the data file Xdata as the classified pixel label data B2[][] of the classified value v2, and the number of bits with a value of 1 in the classified pixel label data is accumulated, assuming it is m2, and the elements in the matrix D[][] whose values ​​are not v1 correspond to the s1*s2-m1 bits in the pixel label data B2[][] in row and column order.

[0158] Set the position marked as 1 in B2[][] to v2 in the matrix D[][]. Similarly, by reading the label data of each classified pixel, the values ​​of each type of pixel in the storage area where the classified label data needs to be stored can be obtained. Reading the classified pixel label data is essentially the inverse process of storing the classified pixel label data mentioned above.

[0159] The number of bits with a value of 1 in each classification label data is accumulated. Assume that there are y=m1+m2+...+mt.

[0160] Step 3.3 reads a series of pixel values ​​of other categories arranged in row and column order.

[0161] Read s*sy 1-byte integer values ​​from the data file Xdata to obtain a series of pixel values ​​of other categories arranged in row and column order. Combined with the various classification label data obtained in the previous step, all pixel values ​​of the storage block can be known.

[0162] If j==z, the pixel position of the requested pixel in the storage block is calculated, the pixel value is obtained, and the reading is completed.

[0163] If j!=z, the requested pixel is not in the storage block, and the next column of storage block data is parsed and processed according to this step.

[0164] This method avoids the situation where storing the labeled data of the classification value may not be worth the cost when there are many types of classified raster data through conditional judgment. For example, there are 16 different classification values ​​in the storage area of ​​4*4 pixels. The method in this paper first performs conditional judgment and stores the labeled data of a certain classification only under the premise of data compression effect. In addition, this method also optimizes the data redundancy problem of classified labeled data and improves the data compression efficiency.

[0165] Taking the national land use classification grid data as an example, there are 13 categories of pixel classification, namely "no data value", "cultivated land", "grassland", "garden", "forest land" and "commercial service land", etc. Under the 30-meter resolution, the usual storage method consists of 134724 rows and 161360 columns of raster pixel data, using 1-byte unsigned integer type value storage, and the total storage space required is about 20.24GB. Applying this method, the value of the storage area s is s=16, and a=8421 and b=10085 storage blocks are obtained. According to statistics, the storage space required for all storage blocks is about 5.36GB; the total storage space required to store the classification information of all storage blocks in each row of a=8421 rows is 8*a bytes, about 66KB, and the metadata information storage space of the original classified raster data Data can be ignored. The total storage space is about 26.5% of the original data storage size. It can be seen that this method greatly saves storage space and there is no error in the classification value of all pixels.

[0166] The lossless compression storage and reading method of classified raster data of the present invention has the following advantages: ensuring the accuracy of each classified pixel value in the classified raster data without error; having a better data compression rate; having no strict constraints on the data, the classification types can be many, the proportion of each classification can be arbitrary, the applicability is very wide, and the promotion and application value is high.

[0167] 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 lossless compression storage method for classified raster data, characterized in that: Storing the original classified raster data Data consisting of K rows and L columns of m types of pixels includes the following steps: S1. Re-dividing the rows and columns of the original classified raster data Data composed of K rows and L columns of pixels with the unit storage area as the minimum granularity to obtain a row and b column storage blocks; When K / s1 is an integer, a=K / s1; When K / s1 is not an integer, a=[K / s1]+1; When L / s2 is an integer, b = L / s2; When L / s2 is not an integer, b=[L / s2]+1; Among them, the unit storage area is a grid data matrix with s1 rows and s2 columns; S2. For a row and b column storage blocks, count the classification information of each storage block row by row and column by column, and store the classification information in the data file Xdata, wherein the classification information includes: the total number of storage block classification tags, each classification value, and classification tag data; record the storage space size of the storage block classification information, and store it in the data file rowSize; S3. Storing metadata information of the original classified raster data Data, and storing the metadata information in a data file meta; In step 2, the total number of classification marks of storage blocks, the values ​​of each classification, and the classification mark data are counted, including the following steps: Arrange all pixel classification values ​​in the storage block in order from most to least according to the total number of pixels to obtain n integer values ​​of d1, d2, ..., dn, that is, n classification pixel values; for these n classification pixel values, determine in order whether the pixels of the classification need to record classification mark data; Whether the pixel with a classification value of dj, 1<=j<=n needs to record the classification mark data is determined by comparison: if the storage space used to record the classification mark data is less than the number of pixels of this classification in the storage block*8, then the classification mark data needs to be recorded; if the storage space used to record the classification mark data is greater than the number of pixels of this classification in the storage block*8, then the classification mark data does not need to be recorded; In this way, the total number of classification marks t and the classification values ​​v1, v2, ..., vt that need to be recorded are obtained; Recording the storage space size used for classification label data includes the following steps: The classification label data B[][] is a two-dimensional array whose size is not fixed; For the classification mark data B[][] with the largest number of pixels and the classification value of d1, it is s1 rows and s2 columns, and the storage space used is s1*s2 bits, which indicates whether a certain pixel in the storage block is a pixel with the classification value of d1; if B[g][h]=0, it means that the pixel in the gth row and hth column in the storage block is not a pixel with the classification value of d1, 1<=g<=s1; 1<=h<=s2; if B[g][h]=1, it means that the pixel in the gth row and hth column in the storage block is a pixel with the classification value of d1, assuming that there are m1 pixels with the classification value of d1 in the storage block; The storage space used for the classification label data B[][] with the classification value d2, which has the second largest number of pixels, is s1*s2-m1 bits, assuming that there are m2 pixels with the classification value d2 in the storage block; similarly, the storage space used for the classification label data B[][] with the classification value d3, which has the second largest number of pixels, is s1*s2-m1-m2 bits; By analogy, the storage space size used for pixel classification label data of all classification values ​​is determined.

2. A method for lossless compression storage of classified raster data according to claim 1, characterized in that: The step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, including the following steps: The value Ts is used to record the byte size required to store the classification information of the current storage block, which is initially 0; the total number of classification tags t that needs to be recorded is stored using an x-byte integer, and the Ts value increases by x; each classification value v1, v2, ..., vt is stored using a 1-byte integer, and the Ts value increases by t.

3. The method for lossless compression storage of classified raster data according to claim 2, characterized in that: The step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, and also includes the following steps: The labeled data B[][] of category i (1<=i<=t) requires ki bits of storage space. If there are t categories of labeled data to be stored in the storage block, then T=k1+k2+...+kt bits of storage space are required; If T is a multiple of 8, the T / 8 byte integer value is stored in bytes, and the Ts value increases by T / 8. If T is not a multiple of 8, you need to add 0 bits at the end to [T / 8]+1 bytes, store this [T / 8]+1 byte integer value, and increase the Ts value by [T / 8]+1.

4. A method for lossless compression storage of classified raster data according to claim 3, characterized in that: The step 2 records the storage space size of the storage block classification information and stores it in the data file rowSize, including the following steps: The pixels in the storage block whose pixel values ​​are not the classification values ​​v1 or v2, ..., or vt are arranged in row and column order to store the pixel values. Assuming there are w pixel values, the Ts value increases by w.

5. The method for lossless compression storage of classified raster data according to claim 4, characterized in that: The cumulative value sumTs of the storage space size Ts of each column storage block in each row is recorded and written into the data file rowSize.

6. A method for lossless compression storage of classified raster data according to claim 5, characterized in that: The metadata information includes the number of rows K and the number of columns L of the original classified raster data Data; the values ​​of storage areas s1 and s2; and the metadata information is written into the data file meta.

7. A method for reading lossless compression of classified raster data, used for reading raster data stored according to a lossless compression method for classified raster data according to any one of claims 4 to 6, 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, 1<=c<=L, the following steps are included: Step 1. Read the data file meta, obtain the metadata information of the original classified raster data Data, obtain the number of rows K and columns L of the original classified raster data Data; the values ​​of storage areas s1 and s2, etc., and calculate that there are a rows and b columns of storage blocks in the data file Xdata; Step 2. Calculate the number of the storage block where the pixel in the rth row and cth column is located. Assuming that the row number of the storage block where the requested pixel is located is v and the column number is z, we can get: When r / s1 is an integer, v=r / s1; When r / s1 is not an integer, v=[r / s1]+1; When c / s2 is an integer, z = c / s2; When c / s2 is not an integer, z=[c / s2]+1; Step 3. Read the data file rowSize and obtain a integer values, e1, e2, ..., ea; wherein e1 indicates that the total classification information storage space of the storage blocks of all columns in the first row is e1 bits, and ea indicates that the total classification information storage space of the storage blocks of all columns in the last row is ea bits; When v=1, the data of the first column storage block of the first row starts at byte 0 of the data file Xdata, and the reading point position offset=0; When v>1, the data of the first column of the storage block in the vth row starts at the e(v-1) byte of the data file Xdata, and the reading point position offset=e(v-1); The data file Xdata is read starting from the offset byte, that is, the storage block at the vth row and the first column is read and parsed, and the information of the storage blocks is parsed one by one.

8. The method for lossless compression reading of classified raster data according to claim 7, characterized in that: The step 3 specifically includes the following steps: assuming that the jth storage block is currently being read, 1<=j<=z; Step 3.1 read the total number of classification marks t and the classification values ​​v1, v2, ..., vt that need to be recorded; Read x bytes from the data file Xdata as the total number of classification tags t; If t>0, read t bytes from the data file Xdata continuously to obtain the classification values ​​v1, v2, ..., vt; If t is 0, execute step 3.3 to read a series of pixel values ​​of other categories arranged in row and column order; Step 3.2 reads the classification mark data to be recorded; Read s1*s2 bits of data from the data file Xdata as the classified pixel label data B1[][] of the classified value v1, and accumulate the number of bits with a value of 1 in the classified pixel label data, assuming it is m1, allocate an integer value matrix D[][] with s1 rows and s2 columns, and set the position marked as 1 in the classified pixel label data B1[][] to v1 in the matrix D[][]. Read s1*s2-m1 bits of data from the data file Xdata as the classified pixel label data B2[][] of the classified value v2, and accumulate the number of bits with a value of 1 in the classified pixel label data, assuming it is m2, and correspond the elements in the matrix D[][] whose values ​​are not v1 to the s1*s2-m1 bits in the pixel label data B2[][] in row and column order; Set the position marked as 1 in B2[][] to v2 in the matrix D[][]. Similarly, by reading the label data of each classified pixel, the values ​​of each type of pixel in the storage area where the classified label data needs to be stored can be obtained. Accumulate the number of bits with a value of 1 in each classification label data, assuming there are y = m1 + m2 + ... + mt; Step 3.3 reads a series of pixel values ​​of other categories arranged in row and column order; Read s1*s2-y 1-byte integer values ​​from the data file Xdata to obtain a series of pixel values ​​of other categories arranged in row and column order; If j == z, then calculate the pixel position of the requested pixel in the storage block, obtain the pixel value, and the reading ends; If j!=z, the requested pixel is not in the storage block, and the next column of storage block data is parsed and processed according to this step.

Citation Information

Patent Citations

  • An access method and device for local effective grid data

    CN103886045B

  • A method for storing and retrieving categorized raster data

    CN107977427B

  • Method for storing and reading classified raster data

    CN115049873A