PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ rt_raster_replace_band()

rt_band rt_raster_replace_band ( rt_raster  raster,
rt_band  band,
int  index 
)

Replace band at provided index with new band.

Parameters
rasterraster of band to be replaced
band: new band to add to raster
index: index of band to replace (0-based)
Returns
NULL on error or replaced band

Definition at line 1404 of file rt_raster.c.

1404  {
1405  rt_band oldband = NULL;
1406  assert(NULL != raster);
1407  assert(NULL != band);
1408 
1409  if (band->width != raster->width || band->height != raster->height) {
1410  rterror("rt_raster_replace_band: Band does not match raster's dimensions: %dx%d band to %dx%d raster",
1411  band->width, band->height, raster->width, raster->height);
1412  return 0;
1413  }
1414 
1415  if (index >= raster->numBands || index < 0) {
1416  rterror("rt_raster_replace_band: Band index is not valid");
1417  return 0;
1418  }
1419 
1420  oldband = rt_raster_get_band(raster, index);
1421  RASTER_DEBUGF(3, "rt_raster_replace_band: old band at %p", oldband);
1422  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", band);
1423 
1424  raster->bands[index] = band;
1425  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", raster->bands[index]);
1426 
1427  band->raster = raster;
1428  oldband->raster = NULL;
1429 
1430  return oldband;
1431 }
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:306
band
Definition: ovdump.py:58
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:385
rt_raster raster
Definition: librtcore.h:2514

References ovdump::band, rt_band_t::raster, rtrowdump::raster, RASTER_DEBUGF, rt_raster_get_band(), and rterror().

Referenced by RASTER_reclass(), RASTER_reclass_exact(), RASTER_setBandPath(), RASTER_setPixelValuesGeomval(), rt_raster_gdal_rasterize(), and test_raster_replace_band().

Here is the call graph for this function:
Here is the caller graph for this function: