PostGIS  2.1.10dev-r@@SVN_REVISION@@
rt_band rt_raster_replace_band ( rt_raster  raster,
rt_band  band,
int  index 

Replace band at provided index with new band.

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

Definition at line 8702 of file rt_api.c.

References ovdump::band, rt_raster_t::bands, rt_raster_t::height, rt_band_t::height, rt_raster_t::numBands, rtrowdump::raster, rt_band_t::raster, RASTER_DEBUGF, rt_raster_get_band(), rterror(), rt_raster_t::width, and rt_band_t::width.

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

8702  {
8703  rt_band oldband = NULL;
8704  assert(NULL != raster);
8705  assert(NULL != band);
8707  if (band->width != raster->width || band->height != raster->height) {
8708  rterror("rt_raster_replace_band: Band does not match raster's dimensions: %dx%d band to %dx%d raster",
8709  band->width, band->height, raster->width, raster->height);
8710  return 0;
8711  }
8713  if (index >= raster->numBands || index < 0) {
8714  rterror("rt_raster_replace_band: Band index is not valid");
8715  return 0;
8716  }
8718  oldband = rt_raster_get_band(raster, index);
8719  RASTER_DEBUGF(3, "rt_raster_replace_band: old band at %p", oldband);
8720  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", band);
8722  raster->bands[index] = band;
8723  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", raster->bands[index]);
8725  band->raster = raster;
8726  oldband->raster = NULL;
8728  return oldband;
8729 }
uint16_t numBands
Definition: rt_api.h:2215
rt_raster raster
Definition: rt_api.h:2249
tuple band
uint16_t height
Definition: rt_api.h:2242
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
uint16_t height
Definition: rt_api.h:2227
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
uint16_t width
Definition: rt_api.h:2226
uint16_t width
Definition: rt_api.h:2241
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_api.c:5686
rt_band * bands
Definition: rt_api.h:2228

Here is the call graph for this function:

Here is the caller graph for this function: