1r.compress(1)                 Grass User's Manual                r.compress(1)
2
3
4

NAME

6       r.compress  - Compresses and decompresses raster maps.
7

KEYWORDS

9       raster
10

SYNOPSIS

12       r.compress
13       r.compress help
14       r.compress [-uq] map=string[,string,...]  [--verbose]  [--quiet]
15
16   Flags:
17       -u
18           Uncompress the map
19
20       -q
21           Run quietly
22
23       --verbose
24           Verbose module output
25
26       --quiet
27           Quiet module output
28
29   Parameters:
30       map=string[,string,...]
31           Name of existing raster map(s)
32

DESCRIPTION

34       The  GRASS  program  r.compress  can be used to compress and decompress
35       raster map layers.
36
37       During compression, this program reformats raster  maps  using  a  run-
38       length-encoding  (RLE) algorithm.  Raster map layers which contain very
39       little information (such as boundary, geology, soils and land use maps)
40       can  be  greatly  reduced in size. Some raster map layers are shrunk to
41       roughly 1% of their original sizes.  Raster map layers containing  com‐
42       plex  images  such  as  elevation  and  photo  or  satellite images may
43       increase slightly in size.  All new raster maps are  now  automatically
44       stored in compressed form (see FORMATS below).  GRASS programs can read
45       both compressed and regular (uncompressed) file formats.   This  allows
46       the use of whichever raster data format consumes less space.
47
48       As an example, the Spearfish data base raster map layer owner was orig‐
49       inally a size of 26600 bytes.  After it was compressed, the raster  map
50       became only 1249 bytes (25351 bytes smaller).
51
52       Raster  files may be decompressed to return them to their original for‐
53       mat, using the -u flag of r.compress. If r.compress is  asked  to  com‐
54       press  a  raster  map  which is already compressed (or to decompress an
55       already decompressed raster map), it simply informs the user the map is
56       already (de)compressed and exits.
57

NOTES

59       r.compress  can  be  run either non-interactively or interactively.  In
60       non-interactive use, the user must specify the name(s)  of  the  raster
61       map  layer(s)  to  be compressed (or decompressed) on the command line,
62       using the form map=name[,name,...] (where each name is the  name  of  a
63       raster  map layer to be compressed or decompressed). The default behav‐
64       ior is to compress the named map(s).
65
66   FORMATS
67       Conceptually, a raster data file consists of rows of cells,  with  each
68       row  containing  the  same  number of cells.  A cell consists of one or
69       more bytes.  The number of bytes per cell depends on the category  val‐
70       ues  stored  in the cell.  Category values in the range 0-255 require 1
71       byte per cell, while category values in the range 256-65535  require  2
72       bytes, and category values in the range above 65535 require 3 (or more)
73       bytes per cell.
74
75       The decompressed raster map format matches the conceptual format.   For
76       example, a raster map with 1 byte cells that is 100 rows with 200 cells
77       per row, consists of 20,000 bytes.  Running the UNIX command ls  -l  on
78       this  file will show a size of 20,000.  If the cells were 2 byte cells,
79       the file would require 40,000 bytes.  The  map  layer  category  values
80       start with the upper left corner cell followed by the other cells along
81       the northern boundary.  The byte following the last byte of that  first
82       row is the first cell of the second row of category values (moving from
83       left to right).  There are no end-of-row markers or other syncing codes
84       in  the  raster map.  A cell header file (cellhd) is used to define how
85       this string of bytes is broken up into rows of category values.
86
87       The compressed format is not so simple, but is  quite  elegant  in  its
88       design.  It not only requires less disk space to store the raster data,
89       but often can result in faster execution of graphic and  analysis  pro‐
90       grams  since  there is less disk I/O. There are two compressed formats:
91       the pre-version 3.0 format (which GRASS programs can read but no longer
92       produce),  and the version 3.0 format (which is automatically used when
93       new raster map layers are created).
94
95   PRE-3.0 FORMAT:
96       First 3 bytes (chars) - These are a special code  that  identifies  the
97       raster data as compressed.
98
99       Address  array  (long)  -  array  (size  of  the number of rows + 1) of
100       addresses pointing to the internal start of each row.  Because each row
101       may  be  a different size, this array is necessary to provide a mapping
102       of the data.
103
104       Row by row, beginning at the northern edge of the  data,  a  series  of
105       byte  groups  describes the data.  The number of bytes in each group is
106       the number of bytes per cell plus one.  The first byte  of  each  group
107       gives a count (up to 255) of the number of cells that contain the cate‐
108       gory values given by the remaining bytes of the group.
109
110   POST-3.0 FORMAT:
111       The 3 byte code is not used.  Instead, a field in the  cell  header  is
112       used to indicate compressed format.
113
114       The address array is the same.
115
116       The  RLE format is the same as the pre-3.0 RLE, except that each row of
117       data is preceded by a single byte containing the number  of  bytes  per
118       cell  for the row, and if run-length-encoding the row would not require
119       less space than non-run-length-encoding, then the row is not encoded.
120
121       These improvements give better compression than the pre-3.0  format  in
122       99%  of  the raster data layers.  The kinds of raster data layers which
123       get bigger are those in which each row would be  larger  if  compressed
124       (e.g.,  imagery  band  files).   But  even in this case the raster data
125       layer would only be larger by the size of the  address  array  and  the
126       single byte preceding each row.
127

SEE ALSO

129       r.support
130

AUTHORS

132       James Westervelt,
133       Michael Shapiro,
134
135       U.S. Army Construction Engineering Research Laboratory
136
137       Last changed: $Date: 2008-02-01 04:38:08 +0100 (Fri, 01 Feb 2008) $
138
139       Full index
140
141       © 2003-2008 GRASS Development Team
142
143
144
145GRASS 6.3.0                                                      r.compress(1)
Impressum