PostGIS  2.4.9dev-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 1502 of file rt_raster.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().

1502  {
1503  rt_band oldband = NULL;
1504  assert(NULL != raster);
1505  assert(NULL != band);
1506 
1507  if (band->width != raster->width || band->height != raster->height) {
1508  rterror("rt_raster_replace_band: Band does not match raster's dimensions: %dx%d band to %dx%d raster",
1509  band->width, band->height, raster->width, raster->height);
1510  return 0;
1511  }
1512 
1513  if (index >= raster->numBands || index < 0) {
1514  rterror("rt_raster_replace_band: Band index is not valid");
1515  return 0;
1516  }
1517 
1518  oldband = rt_raster_get_band(raster, index);
1519  RASTER_DEBUGF(3, "rt_raster_replace_band: old band at %p", oldband);
1520  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", band);
1521 
1522  raster->bands[index] = band;
1523  RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", raster->bands[index]);
1524 
1525  band->raster = raster;
1526  oldband->raster = NULL;
1527 
1528  return oldband;
1529 }
raster
Be careful!! Zeros function&#39;s input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
uint16_t numBands
Definition: librtcore.h:2241
rt_raster raster
Definition: librtcore.h:2275
band
Definition: ovdump.py:57
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
uint16_t height
Definition: librtcore.h:2268
uint16_t height
Definition: librtcore.h:2253
uint16_t width
Definition: librtcore.h:2252
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
uint16_t width
Definition: librtcore.h:2267
rt_band * bands
Definition: librtcore.h:2254
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
Here is the call graph for this function:
Here is the caller graph for this function: