Map and Table Calculation

COLOR( ) function

Returns a new (R,G,B) color from expressions resulting in values for Red, Green and Blue.

Syntax

COLOR(Red, Green, Blue)

Input

Red is a value
Value range: [0,255]
Green is a value
Value range: [0,255]
Blue is a value
Value range: [0,255]

Output

COLOR returns: a color
Domain: system domain Color

Note:

When the input value is undefined or outside the value range [0,255], the output will be (0,0,0).

Tips:

Usable in

MapCalc, TabCalc, Simple calculators

Examples

Pocket line calculator example:

? COLOR(SQ(5),12*3,255/2)

returns (25,36,128)

? COLOR(300,255,?)

returns (0,255,0)

MapCalc example:

LandColor = MAPCOLOR(Landuse)

LandColor2 = IFF((LandColor="Forest",COLOR(80,240,50),COLOR(100,0,200))

 

Landuse

LandColor

LandColor2

Forest Forest Rocks
Shrubs Lake Grass
? Grass Airport
(48,128,76) (48,128,76) (128,128,128)
(255,0,255) (0,0,255) (98,98,98)
(0,0,0) (98,98,98) (255,0,0)
(80,240,50) (80,240,50) (100,0,200)
(100,0,200) (100,0,200) (100,0,200)
(0,0,0) (100,0,200) (100,0,200)

The new map LandColor has the Color domain. In map LandColor2, Forest is assigned a new color (80,240,50) and to all other land use units a color (100,0,200) is assigned).

TabCalc example:

Color = COLOR(R,G,B)

 

Landuse.rpr

Landunit

Colorname

R

G

B

Color

Agriculture

Yellow

124

255

0

(255, 255, 0)

Airport

Red

255

0

0

(255, 0, 0)

Bare soils

Brown

164

40

40

(164, 40, 40)

Forest

Forest Green

48

128

76

(48, 128, 76)

Grass

Yellow Green

98 

98

98

(98, 98, 98)

Lake

Blue

0

0

255

(0, 0, 255)

Riverbed

Cyan

0

255

255

(0, 255, 255)

Rocks

Gray

128

128

128

(128, 128, 128)

Shrubs

Magenta

255

0

255

(255, 0, 255)

Advanced example:

The following example shows a more advanced application of calculating with colors.

We will create a representation of a new map, using two input maps and showing features of both original maps.

The first input map Geology is a geology map with a class domain. The second map DemShad is a Digital Elevation Model (DEM) after application of a shadow filter. This second map was stretched using Histogram Equalization with 16 intervals. This resulted in a hill shading map in 16 gray tones. The input maps Geology and DemShad are crossed, creating a cross table GeolShad.tbt and a cross map GeolShad.mpr. The domain of the newly created table and map is an ID domain and has to be converted to a class domain.

New colors will be assigned according to the land use map Landuse but showing the hill shading as well.

In the representation table Geolshad.rpr we create a new column ClassColor. This column contains for each combination of geology and gray tone, the original colors of the corresponding geology type in the geology map.

The combinations Moraine deposits * Gray tone 1, up to Moraine deposits * Gray tone 16 will all have the same base color as the Moraine deposits in the input geology map.

The following command is used on the command line of the representation table:

ClassColor := Geology.rpr.Color[Geology.tbt.Landuse]

Then, the column Color present in the representation table will be replaced by new colors which also indicate the proportion of the stretch class.

Color

:=

COLOR((CLRRED(ClassColor) * GeolShad.tbt.Demshad/16), (CLRGREEN(ClassColor) * GeolShad.tbt.DemShad/16),(CLRBLUE(ClassColor) * GeolShad.tbt.DemShad/16))

In words:

For each of the color components Red, Green and Blue, the color indicated in column ClassColor is multiplied by the proportion of gray shading. For example Class Moraine deposits * Gray shade 1 will get color values multiplied by 1/16.

See also:

COLOR CLRGREEN CLRYELLOW CLRHUE
MAPCOLOR CLRBLUE CLRMAGENTA CLRSAT
RPRCOLOR CLRCYAN CLRINTENS
    CLRGREY COLORHSI