Construct a new rt_raster from an existing rt_raster and an array of band numbers.
- Parameters
-
raster | : the source raster |
bandNums | : array of band numbers to extract from source raster and add to the new raster (0 based) |
count | : number of elements in bandNums |
- Returns
- a new rt_raster or NULL on error
Definition at line 1435 of file rt_raster.c.
1441 double gt[6] = {0.};
1444 assert(NULL != bandNums);
1446 RASTER_DEBUGF(3,
"rt_raster_from_band: source raster has %d bands",
1452 rterror(
"rt_raster_from_band: Out of memory allocating new raster");
1464 for (i = 0; i <
count; i++) {
1469 rterror(
"rt_raster_from_band: Could not copy band");
1475 RASTER_DEBUGF(3,
"rt_raster_from_band: band created at index %d",
1479 RASTER_DEBUGF(3,
"rt_raster_from_band: new raster has %d bands",
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
void rt_band_destroy(rt_band band)
Destroy a raster band.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
uint16_t rt_raster_get_num_bands(rt_raster raster)
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
int rt_raster_copy_band(rt_raster torast, rt_raster fromrast, int fromindex, int toindex)
Copy one band from one raster to another.
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
References genraster::count, window::gt, rtpixdump::rast, rtrowdump::raster, RASTER_DEBUGF, rt_band_destroy(), rt_raster_copy_band(), rt_raster_destroy(), rt_raster_get_geotransform_matrix(), rt_raster_get_num_bands(), rt_raster_new(), rt_raster_set_geotransform_matrix(), rt_raster_set_srid(), and rterror().
Referenced by RASTER_addBandRasterArray(), RASTER_band(), RASTER_union_finalfn(), rt_raster_clone(), and test_raster_from_band().