GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
raster/color_read.c File Reference

Raster Library - Read color table of raster map. More...

#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Include dependency graph for raster/color_read.c:

Go to the source code of this file.

Functions

int Rast_read_colors (const char *name, const char *mapset, struct Colors *colors)
 Read color table of raster map. More...
 
int Rast__read_colors (const char *element, const char *name, const char *mapset, struct Colors *colors)
 
void Rast_mark_colors_as_fp (struct Colors *colors)
 Mark colors as floating-point. More...
 

Detailed Description

Raster Library - Read color table of raster map.

(C) 1999-2009, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
USACERL and many others

Definition in file raster/color_read.c.

Function Documentation

◆ Rast__read_colors()

int Rast__read_colors ( const char *  element,
const char *  name,
const char *  mapset,
struct Colors colors 
)

Definition at line 115 of file raster/color_read.c.

◆ Rast_mark_colors_as_fp()

void Rast_mark_colors_as_fp ( struct Colors colors)

Mark colors as floating-point.

Sets a flag in the colors structure that indicates that these colors should only be looked up using floating-point raster data (not integer data). In particular if this flag is set, the routine Rast_get_c_colors_min_max() should return min=-255$^3$ and max=255$^3$.

Parameters
colorspointer to Colors structure

Definition at line 393 of file raster/color_read.c.

◆ Rast_read_colors()

int Rast_read_colors ( const char *  name,
const char *  mapset,
struct Colors colors 
)

Read color table of raster map.

The color table for the raster map name in the specified mapset is read into the colors structure. If the data layer has no color table, a default color table is generated and 0 is returned. If there is an error reading the color table, a diagnostic message is printed and -1 is returned. If the color table is read ok, 1 is returned.

This routine reads the rules from the color file. If the input raster map is is a floating-point map it calls Rast_mark_colors_as_fp().

Note: If a secondary color file for map name name exists in the current project, that color file is read. This allows the user to define their own color lookup tables for cell maps found in other mapsets.

Warning message is printed if the color file is missing or invalid.

Parameters
namemap name
mapsetmapset name
[out]colorspointer to Colors structure
Returns
-1 on error
0 if missing, but default colors generated
1 on success

Definition at line 54 of file raster/color_read.c.