.TH r.compress 1grass "" "GRASS 7.2.0" "Grass User's Manual" .SH NAME \fI\fBr.compress\fR\fR \- Compresses and decompresses raster maps. .SH KEYWORDS raster, map management, compression .SH SYNOPSIS \fBr.compress\fR .br \fBr.compress \-\-help\fR .br \fBr.compress\fR [\-\fBup\fR] \fBmap\fR=\fIname\fR[,\fIname\fR,...] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-u\fR" 4m .br Uncompress the map .IP "\fB\-p\fR" 4m .br Print compression information and data type of input map(s) .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBmap\fR=\fIname[,\fIname\fR,...]\fR \fB[required]\fR" 4m .br Name of existing raster map(s) .SH DESCRIPTION \fIr.compress\fR can be used to compress or decompress raster maps. Additionally, it prints information about the compression method and data type of the input raster map(s). .PP All raster maps (those imported for the first time and those newly generated) are compressed by default using the ZLIB compression method (see below). Related no data files (i.e.: NULL files), if present, are not compressed by default unless a specific environment variable is set (GRASS_COMPRESS_NULLS, see below). .PP During compression or re\-compression, \fIr.compress\fR compresses raster maps using the method specified by means of the environment variable GRASS_COMPRESSOR. The default compression method is ZLIB\(cqs \(dqdeflate\(dq algorithm (LZ77\-based). Raster maps that contain very little information (such as boundary, geology, soils and land use maps) can be greatly reduced in size. Some raster maps are shrunk to roughly 1% of their original sizes. All newly generated raster maps are automatically stored as compressed data with varying methods depending on the raster format (i.e., CELL: integer; FCELL: single precision; DCELL: double precision; see below). All GRASS GIS modules are able to read both compressed and uncompressed raster maps. .PP Raster maps that are already compressed might be compressed again, either by setting a different method with GRASS_COMPRESSOR (RLE, ZLIB, LZ4, BZIP2) or, for the case of ZLIB compression, by changing the compression level with the environment variable GRASS_ZLIB_LEVEL. .PP Compressed raster maps may be decompressed using \fIr.compress\fR to return them to their original format, using the \fB\-u\fR flag. If a raster map was already decompressed and the \fB\-u\fR flag is set, the module simply informs the user that the map is already decompressed and exits. .SS TERMINOLOGY .RS 4n .IP \(bu 4n INTEGER map (CELL data type): a raster map of INTEGER type (whole numbers only) .IP \(bu 4n FLOAT map (FCELL data type): a raster map of FLOAT type (4 bytes, 7\-9 digits precision) .IP \(bu 4n DOUBLE map (DCELL data type): a raster map of DOUBLE type (8 bytes, 15\-17 digits precision) .IP \(bu 4n NULL: represents \(dqno data\(dq in raster maps; to be distinguished from 0 (zero) data value .RE .SS OVERVIEW OF AVAILABLE COMPRESSION ALGORITHMS The following compression methods are available (set by export GRASS_COMPRESSOR=\fImethod\fR): .RS 4n .IP \(bu 4n NONE (uncompressed) .IP \(bu 4n RLE (generic Run\-Length Encoding of single bytes; deprecated) .IP \(bu 4n ZLIB (DEFLATE, good speed and compression \- \fBdefault compression\fR) .RS 4n .IP \(bu 4n with zlib compression levels (export GRASS_ZLIB_LEVEL=X): \-1..9 (\-1 is default which corresponds to ZLIB level 6) .IP \(bu 4n note: export GRASS_ZLIB_LEVEL=0 is equal to copying the data as\-is from source to destination .RE .IP \(bu 4n LZ4 (fastest, low compression) .IP \(bu 4n BZIP2 (slowest, high compression) .RE Important: the NULL file compression must be explicitly turned on with export GRASS_COMPRESS_NULLS=1 \- such raster maps can then only be opened with GRASS GIS 7.2.0 or later. NULL file compression can be managed with \fBr.null \-z\fR. .SS COMPRESSION ALGORITHM DETAILS All GRASS GIS raster map types are by default ZLIB compressed, i.e. using ZLIB\(cqs deflate algorithm. Through the environment variable GRASS_COMPRESSOR the compression method can be set to RLE, ZLIB, LZ4, or BZIP2. .PP Integer (CELL type) raster maps can be compressed with RLE if the environment variable GRASS_INT_ZLIB exists and is set to value 0. However, this is not recommended. .PP Floating point (FCELL, DCELL) raster maps never use RLE compression; they are either compressed with ZLIB, LZ4, BZIP2 or are uncompressed. .IP "RLE" 4m .br \fBDEPRECATED\fR Run\-Length Encoding, poor compression ratio but fast. It is kept for backwards compatibility to read raster maps created with GRASS 6. It is only used for raster maps of type CELL. FCELL and DCELL maps are never and have never been compressed with RLE. .IP "ZLIB" 4m .br ZLIB\(cqs deflate is the default compression method for all raster maps. GRASS GIS 7 uses by default 1 as ZLIB compression level which is the best compromise between speed and compression ratio, also when compared to other available compression methods. Valid levels are in the range [1, 9] and can be set with the environment variable GRASS_ZLIB_LEVEL. .IP "LZ4" 4m .br LZ4 is a very fast compression method, about as fast as no compression. Decompression is also very fast. The compression ratio is generally higher than for RLE but worse than for ZLIB. LZ4 is recommended if disk space is not a limiting factor. .IP "BZIP2" 4m .br BZIP2 can provide compression ratios much higher than the other methods, but only for large raster maps (> 10000 columns). For large raster maps, disk space consumption can be reduced by 30 \- 50% when using BZIP2 instead of ZLIB\(cqs deflate. BZIP2 is the slowest compression and decompression method. However, if reading from / writing to a storage device is the limiting factor, BZIP2 compression can speed up raster map processing. Be aware that for smaller raster maps, BZIP2 compression ratio can be worse than other compression methods. .SH NOTES .SS Compression method number scheme The used compression method is encoded with numbers. In the internal cellhd file, the value for \(dqcompressed\(dq is 1 for RLE, 2 for ZLIB, 3 for LZ4, and 4 for BZIP2. .PP Obviously, decompression is controlled by the raster map\(cqs compression, not by the environment variable. .SS Formats Conceptually, a raster data file consists of rows of cells, with each row containing the same number of cells. A cell consists of one or more bytes. For CELL maps, the number of bytes per cell depends on the category values stored in the cell. Category values in the range 0\-255 require 1 byte per cell, while category values in the range 256\-65535 require 2 bytes, and category values in the range above 65535 require 3 (or more) bytes per cell. .PP FCELL maps always have 4 bytes per cell and DCELL maps always have 8 bytes per cell. .PP Since GRASS GIS 7.0.0, the default compression method for Integer (CELL) raster maps is ZLIB and no longer RLE. .SS ZLIB compression levels If the environment variable GRASS_ZLIB_LEVEL exists and its value can be parsed as an integer, it determines the compression level used when newly generated raster maps are compressed using ZLIB compression. This applies to all raster map types (CELL, FCELL, DCELL). .PP If the variable does not exist, or the value cannot be parsed as an integer, ZLIB\(cqs compression level 1 will be used. .SH EXAMPLES Printing of current compression state: .br .nf \fC r.compress compressed_no \-p (method 0: NONE). Data type: \fR .fi .PP Applying RLE compression to a copy of the uncompressed map (not recommended!): .br .nf \fC # compression of map using the deprecated RLE compression g.copy raster=compressed_no,compressed_RLE export GRASS_INT_ZLIB=0 # RLE r.compress compressed_RLE r.compress compressed_RLE \-p is compressed (method 1: RLE). Data type: unset GRASS_INT_ZLIB \fR .fi .PP Applying ZLIB compression to a copy of the uncompressed map: .br .nf \fC # compression of map using ZLIB compression g.copy raster=compressed_no,compressed_ZLIB export GRASS_INT_ZLIB=1 # ZLIB r.compress compressed_ZLIB r.compress compressed_ZLIB \-p is compressed (method 2: ZLIB). Data type: unset GRASS_INT_ZLIB \fR .fi .PP Applying BZIP2 compression to a copy of the ZLIB\-compressed map: .br .nf \fC # compression of map using BZIP2 compression g.copy raster=compressed_ZLIB,compressed_BZIP2 export GRASS_COMPRESSOR=BZIP2 # BZIP2 r.compress compressed_BZIP2 r.compress compressed_BZIP2 \-p is compressed (method 4: BZIP2). Data type: unset GRASS_COMPRESSOR \fR .fi .SH SEE ALSO \fI r.info, r.null, r.support \fR .SH AUTHORS James Westervelt, .br Michael Shapiro, .br U.S. Army Construction Engineering Research Laboratory .br Markus Metz .PP \fILast changed: $Date: 2016\-10\-28 16:02:21 +0200 (Fri, 28 Oct 2016) $\fR .SH SOURCE CODE .PP Available at: r.compress source code (history) .PP Main index | Raster index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2016 GRASS Development Team, GRASS GIS 7.2.0 Reference Manual