Returns a new raster with up to four 8BUI bands (RGBA) from applying a colormap to the user-specified band of the input raster. 
- Parameters
- 
  
    | raster | input raster |  | nband | 0-based index of the band to process with colormap |  | colormap | rt_colormap object of colormap to apply to band |  
 
- Returns
- new raster or NULL on error 
Definition at line 1523 of file rt_mapalgebra.c.
 1534         assert(colormap != NULL);
 
 1541         if (colormap->
nentry < 1) {
 
 1542                 rterror(
"rt_raster_colormap: colormap must have at least one entry");
 
 1548                 rterror(
"rt_raster_colormap: raster has no band at index %d", 
nband);
 
 1554                 rterror(
"rt_raster_colormap: Could not get band at index %d", 
nband);
 
 1561                 rterror(
"rt_raster_colormap: Could not initialize internal variables");
 
 1572         if (colormap->
ncolor < 1) {
 
 1573                 rterror(
"rt_raster_colormap: At least one color must be provided");
 
 1577         else if (colormap->
ncolor > 4) {
 
 1578                 rtinfo(
"More than four colors indicated. Using only the first four colors");
 
 1585         if (arg->
pos == NULL) {
 
 1586                 rterror(
"rt_raster_colormap: Could not allocate memory for valid entries");
 
 1590         for (i = 0, j = 0; i < colormap->
nentry; i++) {
 
 1597                                 rtwarn(
"More than one colormap entry found for NODATA value. Only using first NOTDATA entry");
 
 1607         if (colormap->
method == CM_INTERPOLATE && arg->
npos < 2) {
 
 1608                 rtwarn(
"Method INTERPOLATE requires at least two non-NODATA colormap entries. Using NEAREST instead");
 
 1609                 colormap->
method = CM_NEAREST;
 
 1614                 rtinfo(
"Band at index %d has no NODATA value. Ignoring NODATA entry", 
nband);
 
 1622         if (colormap->
method == CM_INTERPOLATE)
 
 1625         else if (colormap->
method == CM_EXACT)
 
 1632         if (arg->
expr == NULL) {
 
 1633                 rterror(
"rt_raster_colormap: Could not allocate memory for reclass expressions");
 
 1640         for (i = 0; i < arg->
nexpr; i++) {
 
 1642                 if (arg->
expr[i] == NULL) {
 
 1643                         rterror(
"rt_raster_colormap: Could not allocate memory for reclass expression");
 
 1651         for (i = 0; i < colormap->
ncolor; i++) {
 
 1671                         RASTER_DEBUGF(4, 
"NODATA expr[%d]->src (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1680                         RASTER_DEBUGF(4, 
"NODATA expr[%d]->dst (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1694                 for (j = 0; j < arg->
npos; j++) {
 
 1695                         if (colormap->
method == CM_INTERPOLATE) {
 
 1696                                 if (j == arg->
npos - 1)
 
 1716                         else if (colormap->
method == CM_NEAREST) {
 
 1719                                 if (j != arg->
npos - 1) {
 
 1752                         else if (colormap->
method == CM_EXACT) {
 
 1770                         RASTER_DEBUGF(4, 
"expr[%d]->src (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1780                         RASTER_DEBUGF(4, 
"expr[%d]->dst (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1794                 if (colormap->
method == CM_EXACT) {
 
 1811                         RASTER_DEBUGF(4, 
"expr[%d]->src (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1821                         RASTER_DEBUGF(4, 
"expr[%d]->dst (min, max, in, ix, en, ex) = (%f, %f, %d, %d, %d, %d)",
 
 1836                 if (arg->
band == NULL) {
 
 1837                         rterror(
"rt_raster_colormap: Could not reclassify band");
 
 1844                         rterror(
"rt_raster_colormap: Could not add reclassified band to output raster");
 
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
#define RASTER_DEBUGF(level, msg,...)
void rtinfo(const char *fmt,...)
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
int rt_raster_has_band(rt_raster raster, int nband)
Return TRUE if the raster has a band of this number.
void rtwarn(const char *fmt,...)
uint16_t rt_raster_get_num_bands(rt_raster raster)
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_band rt_band_reclass(rt_band srcband, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, rt_reclassexpr *exprset, int exprcount)
Returns new band with values reclassified.
static void _rti_colormap_arg_destroy(_rti_colormap_arg arg)
static _rti_colormap_arg _rti_colormap_arg_init(rt_raster raster)
rt_colormap_entry nodataentry
enum rt_colormap_t::@12 method
struct rt_reclassexpr_t::rt_reclassrange src
struct rt_reclassexpr_t::rt_reclassrange dst
 
References _rti_colormap_arg_destroy(), _rti_colormap_arg_init(), _rti_colormap_arg_t::band, ovdump::band, rt_colormap_entry_t::color, rt_reclassexpr_t::dst, rt_colormap_t::entry, rt_reclassexpr_t::rt_reclassrange::exc_max, rt_reclassexpr_t::rt_reclassrange::exc_min, _rti_colormap_arg_t::expr, _rti_colormap_arg_t::hasnodata, rt_reclassexpr_t::rt_reclassrange::inc_max, rt_reclassexpr_t::rt_reclassrange::inc_min, rt_colormap_entry_t::isnodata, rt_reclassexpr_t::rt_reclassrange::max, rt_colormap_t::method, rt_reclassexpr_t::rt_reclassrange::min, pixval::nband, rt_colormap_t::ncolor, rt_colormap_t::nentry, _rti_colormap_arg_t::nexpr, _rti_colormap_arg_t::nodataentry, _rti_colormap_arg_t::nodataval, _rti_colormap_arg_t::npos, _rti_colormap_arg_t::pos, PT_8BUI, _rti_colormap_arg_t::raster, rtrowdump::raster, RASTER_DEBUGF, rt_band_get_hasnodata_flag(), rt_band_get_nodata(), rt_band_reclass(), rt_raster_add_band(), rt_raster_get_band(), rt_raster_get_num_bands(), rt_raster_has_band(), rt_raster_is_empty(), rtalloc(), rterror(), rtinfo(), rtwarn(), rt_reclassexpr_t::src, and rt_colormap_entry_t::value.
Referenced by RASTER_colorMap(), and test_raster_colormap().