1r.compress(1) Grass User's Manual r.compress(1)
2
3
4
6 r.compress - Compresses and decompresses raster files.
7
9 raster
10
12 r.compress
13 r.compress help
14 r.compress [-uq] map=string[,string,...]
15
16 Flags:
17 -u Uncompress the map
18
19 -q Run quietly
20
21 Parameters:
22 map=string[,string,...]
23 Name of existing raster map(s)
24
26 The GRASS program r.compress can be used to compress and decompress
27 raster map layers.
28
29 During compression, this program reformats raster files using a run-
30 length-encoding (RLE) algorithm. Raster map layers which contain very
31 little information (such as boundary, geology, soils and land use maps)
32 can be greatly reduced in size. Some raster map layers are shrunk to
33 roughly 1% of their original sizes. Raster map layers containing com‐
34 plex images such as elevation and photo or satellite images may
35 increase slightly in size. GRASS uses a new compressed format, and all
36 new raster files are now automatically stored in compressed form (see
37 FORMATS below). GRASS programs can read both compressed and regular
38 (uncompressed) file formats. This allows the use of whichever raster
39 data format consumes less space.
40
41 As an example, the Spearfish data base raster map layer owner was orig‐
42 inally a size of 26600 bytes. After it was compressed, the raster file
43 became only 1249 bytes (25351 bytes smaller).
44
45 Raster files may be decompressed to return them to their original for‐
46 mat, using the -u option of r.compress. If r.compress is asked to com‐
47 press a raster file which is already compressed (or to decompress an
48 already decompressed file), it simply informs the user of this and asks
49 the user if he wishes to perform the reverse operation.
50
52 r.compress can be run either non-interactively or interactively. In
53 non-interactive use, the user must specify the name(s) of the raster
54 map layer(s) to be compressed (or decompressed) on the command line,
55 using the form map=name[,name,...] (where each name is the name of a
56 raster map layer to be compressed or decompressed). To decompress a
57 map, the user must include the -u option on the command line. If the -u
58 option is not included on the command line, r.compress will attempt to
59 compress the named map layer(s).
60
61 If the user simply types r.compress without specifying any map layer
62 name(s) on the command line, r.compress will prompt the user for the
63 names of the map layers to be compressed/decompressed, and ask whether
64 these maps are to be compressed or decompressed.
65
66 If the -u flag is set, r.compress converts a compressed map to its
67 uncompressed format. If not set, r.compress will attempt to compress
68 the named map layer(s).
69
71 Conceptually, a raster data file consists of rows of cells, with each
72 row containing the same number of cells. A cell consists of one or
73 more bytes. The number of bytes per cell depends on the category val‐
74 ues stored in the cell. Category values in the range 0-255 require 1
75 byte per cell, while category values in the range 256-65535 require 2
76 bytes, and category values in the range above 65535 require 3 (or more)
77 bytes per cell.
78
79 The decompressed raster file format matches the conceptual format. For
80 example, a raster file with 1 byte cells that is 100 rows with 200
81 cells per row, consists of 20,000 bytes. Running the UNIX command ls
82 -l on this file will show a size of 20,000. If the cells were 2 byte
83 cells, the file would require 40,000 bytes. The map layer category
84 values start with the upper left corner cell followed by the other
85 cells along the northern boundary. The byte following the last byte of
86 that first row is the first cell of the second row of category values
87 (moving from left to right). There are no end-of-row markers or other
88 syncing codes in the raster file. A cell header file (cellhd) is used
89 to define how this string of bytes is broken up into rows of category
90 values.
91
92 The compressed format is not so simple, but is quite elegant in its
93 design. It not only requires less disk space to store the raster data,
94 but often can result in faster execution of graphic and analysis pro‐
95 grams since there is less disk I/O. There are two compressed formats:
96 the pre-version 3.0 format (which GRASS programs can read but no longer
97 produce), and the version 3.0 format (which is automatically used when
98 new raster map layers are created).
99
100 PRE-3.0 FORMAT:
101 First 3 bytes (chars) - These are a special code that identifies the
102 raster data as compressed.
103
104 Address array (long) - array (size of the number of rows + 1) of
105 addresses pointing to the internal start of each row. Because each row
106 may be a different size, this array is necessary to provide a mapping
107 of the data.
108
109 Row by row, beginning at the northern edge of the data, a series of
110 byte groups describes the data. The number of bytes in each group is
111 the number of bytes per cell plus one. The first byte of each group
112 gives a count (up to 255) of the number of cells that contain the cate‐
113 gory values given by the remaining bytes of the group.
114
115 POST-3.0 FORMAT:
116 The 3 byte code is not used. Instead, a field in the cell header is
117 used to indicate compressed format.
118
119 The address array is the same.
120
121 The RLE format is the same as the pre-3.0 RLE, except that each row of
122 data is preceded by a single byte containing the number of bytes per
123 cell for the row, and if run-length-encoding the row would not require
124 less space than non-run-length-encoding, then the row is not encoded.
125
126 These improvements give better compression than the pre-3.0 format in
127 99% of the raster data layers. The kinds of raster data layers which
128 get bigger are those in which each row would be larger if compressed
129 (e.g., imagery band files). But even in this case the raster data
130 layer would only be larger by the size of the address array and the
131 single byte preceding each row.
132
134 r.support
135
137 James Westervelt,
138 Michael Shapiro,
139
140 U.S. Army Construction Engineering Research Laboratory
141
142 Last changed: $Date: 2003/05/06 12:55:35 $
143
144 Full index
145
146
147
148GRASS 6.2.2 r.compress(1)