## Elevation to Color

### Overview

The elevation file is used to enhance the TIGER texture file: a palette is used to convert elevation values to color values, and those colors are draped over the terrain.

The TIGER texture image usually blends with those colors. Certain information from the TIGER texture is not changed: roads and water bodies should be painted independent from the elevation. Therefore a form of selective masking is used.

| This is an elevation file. Each pixel contains an RGB (red, green, blue) value represented by one byte. Therefore, 2^24 = 16777216 different colors can be stored in one pixel. We don't store colors in the first place, but elevation values. Black (R=0/G=0/B=0) is elevation 0, (R=0/G=0/B=1) is 1, (R=0/G=1/B=0) is 256, and so forth.
| The elevation file is converted to a color file using a palette. This is the palette used (lower terrain is left):
| This is how the TIGER texture image initially looks after the download.
| The TIGER texture image is mapped over the color file. White TIGER texture pixels are considered transparent. Other TIGER texture pixels (pink, yellow, light green and dark green) are blended with the underlying color. Again, other TIGER texture pixels are copied to the target image. See legend TGA file below.

### Legend TGA File

For mixing the TIGER texture with the color file, three different methods are used:

- Transparency: white TIGER texture pixels are transparent. The color file pixels are copied to the target image.
- Blending: other TIGER texture pixels are blended with the color file pixels.
- Copying (opaqueness): the rest of the TIGER texture pixels are copied to the target image.

You may use a file "legend.tga" to control the colors which are transparent and which are blended. That file has to reside in the current working directory and has to have only two rows of pixels (height = 2). The width is arbitrary.

- The top row contains all colors considered transparent, one per pixel.
- The bottom (second) row contanis all colors used for blending, one per pixel.

Whichever row is shorter may be filled up with a copy of one of the existing pixels in that row.

Example (note that this is a 2 by 4 pixel file, greatly enlarged here):

Result: All white TIGER texture pixels are transparent (first row). All pink, green, yellow TIGER texture pixels are blended with the color file pixels. All other pixels are copied. Therefore all water bodies have the same color, regardless their elevation.