Compression (Environment setting)
Tools that honor the Compression environment setting will set the compression type when storing output raster datasets.
The primary benefits of compressing data are that compressed data requires less storage space, and data display times will be quicker because there is less information to transmit.
ArcGIS can store compressed data in the following formats: IMG, JPEG, JPEG 2000, TIFF, Grid, file geodatabase, personal geodatabase, and ArcSDE geodatabase. When storing data in the geodatabase, the blocks of data are compressed before they are stored.
Data compression can be lossy (JPEG and JPEG 2000) or lossless (LZ77, PackBits, CCITT). Lossless compression means that the values of cells in the raster dataset are not changed or lost. You should choose lossless or no compression if the pixel values of the raster dataset will be used for analysis or deriving other data products.
The amount of compression will depend on the data and compression quality. The more homogeneous the data, the higher the compression ratio. The lower the compression quality, the higher the compression ratio. Lossy compression normally results in higher compression ratios when compared to lossless compression.
Usage notes
- When storing data in a geodatabase, compression occurs before storage in the geodatabase.
- JPEG compression only works for unsigned 8-bit raster data.
- If JPEG or JPEG 2000 is selected, you can also set the compression quality to control how much loss the image will be subjected to by the compression algorithm. The values of the pixels of an image compressed with a higher compression quality will be closer to those of the original image. Valid value ranges of compression quality are from 1 to 100. The default compression quality is 75. If you don't explicitly set a value, the default will be used.
- The default compression type is LZ77, and it works for all types of raster data.
- The following table summarizes the valid compression types for each pixel depth:Valid compressions for each pixel depth
Valid compressions for each pixel depthCompression
Pixel Depth (8 bit)
Pixel Depth (16 bit)
Additional information
LZ77
Yes
Yes
Any pixel depth
JPEG
Yes
No
JPEG2000
Yes
Yes
PackBits
Yes
No
1-bit to 8-bit data
LZW
Yes
Yes
Any pixel depth
RLE
Yes
Yes
Any pixel depth
CCITT_G3
No
No
Only for 1-bit data
CCITT_G4
No
No
Only for 1-bit data
CCITT_1D
No
No
Only for 1-bit data
- This setting is used for tools that create raster datasets in ArcGIS. Refer to Raster Storage Matrix to see which raster storage formats can be controlled when using this setting.
Dialog syntax
- Compression—Choose which compression method to use when storing your data.
- LZ77—Lossless compression that preserves all raster cell values. This is the default.
- JPEG—Lossy compression that uses the public JPEG compression algorithm. If you choose JPEG, you can also specify the compression quality. The valid compression quality value ranges are from 0 to 100, with 75 being the default. This compression can be used for JPEG files, TIFF files, and geodatabases.
- JPEG2000—Uses wavelet technology so rasters appear lossless. If you choose JPEG2000, you can also specify the compression quality. The valid compression quality value ranges are from 0 to 100, with 75 being the default. This compression can be used for JPEG 2000 files and geodatabases.
- PackBits—PackBits compression for TIFF files.
- LZW—Lossless compression that preserves all raster cell values.
- RLE—Run length encoding for IMG files.
- CCITT_G3—Lossless compression for 1-bit data.
- CCITT_G4—Lossless compression for 1-bit data.
- CCITT_1D—Lossless compression for 1-bit data.
- None—No compression will occur.
- Compression quality (1-100)—When JPEG or JPEG2000 compression is chosen, the compression quality also needs to be specified. The valid compression quality value ranges are from 1 to 100, with 75 being the default.
Scripting syntax
arcpy.env.compression = "compression_type {value}"
Parameters |
Explanation |
---|---|
compression_type (Required) |
|
value (Optional) | When JPEG or JPEG2000 compression is chosen, the compression quality also needs to be specified. The valid compression quality value ranges are from 1 to 100, with 75 being the default. |
import arcpy # Set the compression environment to LZ77. arcpy.env.compression = "LZ77" # Set the compression environment to JPEG with a quality of 80. arcpy.env.compression = "JPEG 80"