Raster maps are pixel images of a map. The are often used as the basic layer, on which we draw vector shape layers, as for examplen roads, rail roads, rivers etc ...
With the
MapServer, we can display raster layers in differant image formats, for example
JPEG,
GIF,
PNG,
TIFF, ect ...

In the
GeoTIFF format, the geographical meta data is included in the image file.
If we do not use
SubjectGeoTIFF, we must keep the geographical meta information about the the raster map, in a separate location. The
MapServer can only handle images, if geographical information about the map is supplied, i.e. the geographical projection, the pixel size and the extent of the map. If we use
SubjectGeoTIFF raster maps, the
MapServer takes the geographical information from the image file.

If we handle the
GeoTIFF with a none Geo capable TIFF software, we lose the meta geographical information. To handle the geographical information of
GeoTIFF files, we use the
GeoTIFF utility.

Here your find a FAQ about
geoTIFF.
Table of Contents
We use the
SubjectGeoTIFF library tool to handle the geographical information of
SubjectGeoTIFF file. To install it on a Linux operating system,
we get the package:
# apt-get install geotiff-bin
The
SubjectGeoTIFF is a library which is provided with two command line executables, allowing to extract the geographical information from
SubjectGeoTIFF files - or to insert a geographical information into a comment TIFF files, so to get a
SubjectGeoTIFF files.
The Command Line listgeo
The usage of
listgeo is:
Usage: listgeo [-d] [-tfw] [-proj4] [-no_norm] [-t tabledir] filename
-d: report lat/long corners in decimal degrees instead of DMS.
-tfw: Generate a .tfw (ESRI TIFF World) file for the target file.
-proj4: Report PROJ.4 equivelent projection definition.
-no_norm: Don't report 'normalized' parameter values.
filename: Name of the GeoTIFF file to report on.
For NASA satelif
SubjectGeoTIFF image of the earth, we get with:
# listgeo map.TIFF
the geographical information:
Geotiff_Information:
Version: 1
Key_Revision: 1.1
Tagged_Information:
ModelTiepointTag (2,3):
0 0 0
-180 90 0
ModelPixelScaleTag (1,3):
0.1 0.1 0
End_Of_Tags.
Keyed_Information:
GTModelTypeGeoKey (Short,1): ModelTypeGeographic
GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
GeographicTypeGeoKey (Short,1): GCS_WGS_84
End_Of_Keys.
End_Of_Geotiff.
GCS: 4326/WGS 84
Datum: 6326/World Geodetic System 1984
Ellipsoid: 7030/WGS 84 (6378137.00,6356752.31)
Prime Meridian: 8901/Greenwich (0.000000/ 0d 0' 0.00"E)
Corner Coordinates:
Upper Left (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left (180d 0' 0.00"W, 90d 0' 0.00"S)
Upper Right (180d 0' 0.00"E, 90d 0' 0.00"N)
Lower Right (180d 0' 0.00"E, 90d 0' 0.00"S)
Center ( 0d 0' 0.00"E, 0d 0' 0.00"S)
In the first block, we find the important information about the pixel size. In our case we have a pixel size of
0.1.
In the second block, we get the information about the map projection. In our case is is a
latlong WBS84 projection
In last block, we find the geographical extent of the map. In our case, we have a map of the entire earth, from
the lower left corner at
(-180°, -90°) to the upper right corner at
(180°, 90°).
With the option
-no_norm we only get the first Geo information block, which is really needed.
With the options
-proj4 we get the geographical projection of map:
PROJ.4 Definition: +proj=latlong +ellps=WGS84 +to_meter=1.0000000000

The projection definition does not affect the pixel maping, because the TIFF image is any way in the Mecador projection.
With the option
-twf, we get the
ESRI TIFF World File:
0.1000000000
0.0000000000
0.0000000000
-0.1000000000
-179.9500000000
89.9500000000
Specification of ESRI TIFF World File
The content of the twf TIFF worldfile are six numbers:
A
B
C
D
E
F
of the coordinate transformation from pixel coordinates
(x, y) to geographical coordinates
(Xg, Yg):
Xg = A * x + C * y + E
Yg = B * x + D * y + F
The origin of the pixel map is at the upper left (north west) corner of the map.
In a typical (north up) arrangement, we have only a latitude and longitude scaling (with out any rotation) and a translation of the pixel origin, so that:
A = pixel width in geounits
B = 0
C = 0
D = pixel height in geounits (normally negative)
E = top left X geo location
R = top left Y geo location

We must take care, how pixel are counted. Pixels may be counted from there upper left corner
or from the center. In the NASA case above, the pixel origin is at the center. Because the latitude pixel width and longitude pixel height are 0.1° the pixel map origin is at (-179,5°, 89,95°) and not (-180°, 90°).

The geoTiff map has a uniform latitude and longitude pixel rate. We there for have bigger pixel resolution at the earth poles. With out a projection correction, the map is by default, in the Mecator projection.
The Command Line geotifcp
If we have a simple TIFF image file, we can remake a
SubjectGeoTIFF with the command
geotifcp. The usage is:
usage: gtiffcp [options] input... output
where options are:
-g file install GeoTIFF metadata from <file>
-e file install positioning info from ESRI Worldfile <file>
-a append to output instead of overwriting
-o offset set initial directory offset
-p contig pack samples contiguously (e.g. RGBRGB...)
-p separate store samples separately (e.g. RRR...GGG...BBB...)
-s write output in strips
-t write output in tiles
-i ignore read errors
-d truncate 8 bitspersample to 4bitspersample
-r # make each strip have no more than # rows
-w # set output tile width (pixels)
-l # set output tile length (pixels)
-f lsb2msb force lsb-to-msb FillOrder for output
-f msb2lsb force msb-to-lsb FillOrder for output
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c jpeg[:opts]compress output with JPEG encoding
-c packbits compress output with packbits encoding
-c g3[:opts] compress output with CCITT Group 3 encoding
-c g4 compress output with CCITT Group 4 encoding
-c none use no compression algorithm on output
Group 3 options:
1d use default CCITT Group 3 1D-encoding
2d use optional CCITT Group 3 2D-encoding
fill byte-align EOL codes
For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs
JPEG options:
# set compression quality level (0-100, default 75)
r output color image as RGB rather than YCbCr
For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing
To remake a geoTIFF from a simple TIFF file from which we known TWF file, we can do:
geotifcp -e map.tfw modified.tif modified_map.TIFF
If we also know the projection definition of the map, we can do:
geotifcp -e map.tfw -g map.geo modified.tif modified-map.TIFF
To perserve the Geo metadata informtaion, we can simple to:
listgeo -no_norm map.TIFF > map.geo
geotifcp -g map.geo modified.tif modified_map.TIFF

The TIFF image content of a
SubjectGeoTIFF map file can be handled with the C library
libtiff-tools.
--
TWikiAdminUser - 2009-12-15