Generate a new inline band and add it to a raster.
- Parameters
-
raster | : the raster to add a band to |
pixtype | : the pixel type for the new band |
initialvalue | : initial value for pixels |
hasnodata | : indicates if the band has a nodata value |
nodatavalue | : nodata value for the new band |
index | : position to add the new band in the raster |
- Returns
- identifier (position) for the just-added raster, or -1 on error
Memory is allocated in this function for band data.
- Parameters
-
raster | : the raster to add a band to |
pixtype | : the pixel type for the new band |
initialvalue | : initial value for pixels |
hasnodata | : indicates if the band has a nodata value |
nodatavalue | : nodata value for the new band |
index | : position to add the new band in the raster |
- Returns
- identifier (position) for the just-added raster, or -1 on error
Definition at line 489 of file rt_raster.c.
509 else if (index > oldnumbands + 1)
510 index = oldnumbands + 1;
515 numval = width * height;
518 mem = (
int *)
rtalloc(datasize);
520 rterror(
"rt_raster_generate_new_band: Could not allocate memory for band");
526 rterror(
"rt_raster_generate_new_band: Could not add band to raster. Aborting");
536 if (numbands == oldnumbands || index == -1) {
537 rterror(
"rt_raster_generate_new_band: Could not add band to raster. Aborting");
543 if (hasnodata &&
FLT_EQ(initialvalue, nodatavalue))
void rt_band_init_value(rt_band band, double initval)
Fill in the cells of a band with a starting value frequently used to init with nodata value.
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
void rt_band_set_ownsdata_flag(rt_band band, int flag)
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag)
Set isnodata flag value.
void rt_band_destroy(rt_band band)
Destroy a raster band.
void rtdealloc(void *mem)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
uint16_t rt_raster_get_num_bands(rt_raster raster)
uint16_t rt_raster_get_height(rt_raster raster)
uint16_t rt_raster_get_width(rt_raster raster)
References ovdump::band, FLT_EQ, rtrowdump::raster, rt_band_destroy(), rt_band_init_value(), rt_band_new_inline(), rt_band_set_isnodata_flag(), rt_band_set_ownsdata_flag(), rt_pixtype_size(), rt_raster_add_band(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_width(), rtalloc(), rtdealloc(), and rterror().
Referenced by RASTER_addBand(), RASTER_clip(), RASTER_mapAlgebra2(), RASTER_mapAlgebraExpr(), RASTER_mapAlgebraFct(), RASTER_mapAlgebraFctNgb(), RASTER_tile(), RASTER_union_transfn(), rt_raster_from_gdal_dataset(), rt_raster_iterator(), and test_raster_get_pixel_bilinear().