TIFF (TIF)

Long name TIFF 6.0
Short name TIF
File extension(s) .tif, .tiff, .tjp, .tifw, .tfw, .tab

The GDB library supports most common forms of Tagged Image File Format (TIFF) and GeoTIFF files. In particular, it is possible to read .tiff B (Bitmap), .tiff R (RGB), .tiff P (Palette), and .tiff G (Grayscale). A variety of compression schemes are allowed. Cloud Optimized GeoTIFF (COG) files are also supported for both reading and creating.

The TIFF was designed to be an extendable, all-purpose standard for image interchange. A TIFF file consists of an image and a list of information tags describing the image. A variety of image orderings, with various types of compression, is possible using TIFF files. The format is extendible, because new information tags can be added at will; a TIFF-file reader is required to ignore unrecognized tags.

Because it is realistically impossible for a TIFF reader to read all possible TIFF files, a small number of TIFF subset classifications have been developed. Requirements for reading and writing these classified files have also been developed.

TIFF G files contain one channel of imagery; TIFF B files contain a single bitmap; TIFF P files contain a single channel of imagery and a pseudocolor segment. TIFF R files contain three image channels (RGB).

PCI support for TIFF files includes the following bit depths: 8U, 16S, 16U, 32S, 32U, 32R, 64S, 64U, 64R, C16S, C32S, C32R. Additionally, PCI can read and create 1 bit rasters in a TIFF as bitmaps.

The following are the valid configurations possible for a TIFF file:
  • 1 Channel: Results in a TIFF G (or grayscale) file
  • 1 Channel + PCT: Results in a TIFF P (or pseudocolored) file
  • 3 Channels: Results in a TIFF RGB file
  • 1 Bitmap: Results in a TIFF B (or bitmap) file
  • 4+ Channels: Results in a TIFF RGB file with additional data bands

TIFF files do not support lookup tables (LUT).

When reading data, Exchangeable image file format (Exif) tags are imported as metadata, which contain specific image properties.

Georeferencing

Georeferencing information in GeoTIFF format can be written to, and extracted from, TIFF files. GeoTIFF is a standard adopted widely by the geomatics industry. Projections supported by PCI software include UTM, State Plane, Geographic, Lambert Conformal Conic, Transverse Mercator, Mercator, Stereographic Double Oblique, and Oblique Mercator, and some others. Images with GeoTIFF georeferencing, including a rotation, are also supported.

Georeferencing information is exported in GeoTIFF format by default.

If GeoTIFF information is unavailable, but an ESRI-style TIFF world file is (with a file name extension of .tifw or .tfw), then it will be read for georeferencing information. However, the map units will always be set to METER or LON/LAT, since the world file does not contain the projection information. A LON/LAT projection will be assigned if the offset ranges from -180 to 180 and from -90 to 90. The use of rotation coefficients in the world file is supported in GDB.

MapInfo style georeferencing is also supported. MapInfo stores the projection definition and image georeferencing in a .tab file. The .tab file will have the same base name as the TIFF file.

TIFF and RPC files

A TIFF file can have an associated rational functions math (RPC) model binary segment. The binary RPC segment will be created if the TIFF file has an associated RPC file (Quickbird format .rpb/.txt or Ikonos format _rpc.txt). For example, an Ikonos RPC file for a TIFF file, image1.tif, will be named image1_rpc.txt. The text file provides the coefficients that define the rational functions math model for the scene.

Creating TIFF files

The supported classes have a variety of possible compression schemes, of which JPEG, LZW, ZIP, PackBits, CCITT 3 Fax, and CCITT 4 Fax are known to work.

The following options are available to select different compression schemes:
  • NONE: No compression (default option)
  • PACKBITS: Macintosh RLE PackBits format. This compression type is similar to a run length encoded compression and is more suited for thematic rasters.
  • FAX3: CCITT Fax 3, suitable only for bitmaps
  • FAX4: CCITT Fax 4, suitable only for bitmaps
  • JPEG: JPEG compression
  • LZW: Lempel-Ziv Welch lossless compression
  • ZIP: Deflate lossless compression

With the JPEG option, a compression quality value can be used. The valid range of compression values ranges from 1 through 100. A value of 100, that is JPEG100, gives the best image quality with the least amount of compression, while a value of 1, that is JPEG1, gives the poorest image quality, but has the most compression. The default value is 75.

Note: Only 8-bit rasters can be compressed by using JPEG compression.
The following options can be provided to control the interleaving format of the resulting file:
  • BAND: produces a band interleaved file.
  • PIXEL: produces a pixel interleaved file.
  • TILED[nnn]: produces a tiled file.

Often TIFF files are written as a single image; however, with the TILED option, the TIFF file can be written as a series of smaller image tiles. The default size is tiles of 256 x 256 pixels .This can be useful for faster localized loading of the resulting TIFF file. For example, an option value of "TILED512" would generate an image split into tiles of 512 x 512 pixels.

 option = "TILED512"
			

You can also specify a compression method with the TILED option:

 option = "TILED512 JPEG"
			

To create an Arc/Info-style TIFF World file, you can append the option value with the keyword WORLD, separated from other text by a space.

 option = "WORLD"          | Uncompressed with World file
 option = "PACKBITS WORLD" | PACKBITS Compressed with World
			
GDB will write a projection definition in the GeoTIFF PCSCitationGeoKey tag if one of the following conditions is met:
  • There does not exist a GeoTIFF datum for the PCI datum. In this case, an ESRI Well Known Text (WKT) will be written.
  • The ESRI option is specified.
To create an ESRI projection WKT in the PCSCitationGeoKey tag, you can append the option value with the keyword ESRI, separated from other text by a space.
 option = "ESRI"          | ESRI projection WKT
 option = "ESRI WORLD"    | ESRI projection WKT with World file

You can also append the value with the keyword MAPINFO to create a MapInfo .tab file, which MapInfo uses to store the georeferencing information.

 option = "PACKBITS MAPINFO" | PACKBITS with MapInfo file for georeferencing

By default, GeoTIFF information is written to each TIFF file created. Some packages cannot read a TIFF file with GeoTIFF info. If this occurs, the keyword NOGEOTIFF can be added to the options string to exclude GeoTIFF information.

 option = "NOGEOTIFF"          | Uncompressed without GeoTIFF
 option = "PACKBITS NOGEOTIFF" | PACKBITS without GeoTIFF info

Sparse tiles

By default, when creating a TIFF using TILED interleaving PCI will attempt to create so-called "TIFF sparse files". A sparse tile is one that has pixels with a value of 0 exclusively, such that it can be defined but the pixels are not allocated storage space. This allows for smaller file sizes and quicker data access. Note that some TIFF reading applications may not be able to read such a file. To prevent the creation of sparse files, the default behavior can be overridden by specifying "SPARSE=NO" as part of the creation option.

 option = "TILED512 SPARSE=NO"          | Do not create sparse tiles
		

Large file handling

A TIFF file is limited to 4 GB in size. However, this limitation is removed in the format BigTIFF. GDB supports BigTIFF for both reading and writing. The export options for BigTIFF are:
  • BigTIFF=AUTO
  • BigTIFF=ALWAYS
  • BigTIFF=NEVER

The default setting is BigTIFF=AUTO. With this option selected, a TIFF file is created as a regular classic TIFF when the total image size is less than 4 GB. If the size of the uncompressed imagery is greater than 4 GB, a BigTIFF file is created instead. The BigTIFF=ALWAYS and BigTIFF=NEVER options let you override this automatic behavior.

BigTIFF=ALWAYS means that a BigTIFF file is created regardless of the size: it can be less than 4 GB.

BigTIFF=NEVER means that only a classic TIFF file is created. When the imagery is being written uncompressed and it is bigger than 4 GB, an error message is produced. When a classic TIFF is created with compressed imagery, and the imagery is greater than 4 GB, a warning message is produced.

The total image size represents the amount of space that the data for the image will occupy on disk. This is calculated as the number of rows, times the number of columns, times the number of channels, times the byte depth. The byte depth is the number of bytes required to store the value for one pixel. The total image size is used as an approximation of the file size, assuming that the data is uncompressed.

With uncompressed images that are close to 4 GB, or with compressed images that exceed 4 GB, the automatic setting for the BigTIFF option may create a BigTIFF file when a classic TIFF is adequate. For this reason, the BigTIFF=NEVER option can be used to force the creation of a classic TIFF.

Cloud Optimized GeoTIFF

PCI can read and create Cloud Optimized GeoTIFF (COG) files. A COG is a GeoTIFF file created in such a manner to be particularly efficient for reading when that file is hosted on the cloud (on a HTTP/HTTPS server). To access a COG dataset with PCI software, simply open it using the full URL to the .tif file. To create a cloud optimized GeoTIFF, you use the keyword "CLOUD". For best results, the raster data you want to write to a Cloud Optimized GeoTIFF should have existing overviews.

 option = "CLOUD"     | Create a Cloud Optimized GeoTIFF
			

Acknowledgements

PCI thanks Sam Leffler and SGI for providing the "libtiff" TIFF library, on which all of the PCI TIFF support is based. PCI also thanks Niles D. Ritter of the USGS, who wrote the libgeotiff library on which the PCI GeoTIFF support is based.

For information on the libtiff library, go to simplesystems.org/libtiff.

For information on the GeoTIFF standard, go to ogc.org/standards/geotiff.

© PCI Geomatics Enterprises, Inc.®, 2024. All rights reserved.