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 1439 of file rt_raster.c.
References rt_raster_t::bands, genraster::count, window::gt, rt_raster_t::height, rtpixdump::rast, 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(), rterror(), rt_raster_t::srid, and rt_raster_t::width.
Referenced by RASTER_addBandRasterArray(), RASTER_band(), RASTER_union_finalfn(), rt_raster_clone(), and test_raster_from_band().
1445 double gt[6] = {0.};
1447 assert(NULL != raster);
1448 assert(NULL != bandNums);
1450 RASTER_DEBUGF(3,
"rt_raster_from_band: source raster has %d bands",
1456 rterror(
"rt_raster_from_band: Out of memory allocating new raster");
1468 for (i = 0; i <
count; i++) {
1473 rterror(
"rt_raster_from_band: Could not copy band");
1479 RASTER_DEBUGF(3,
"rt_raster_from_band: band created at index %d",
1483 RASTER_DEBUGF(3,
"rt_raster_from_band: new raster has %d bands",
int rt_raster_get_num_bands(rt_raster raster)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
void rt_band_destroy(rt_band band)
Destroy a raster band.
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
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.
#define RASTER_DEBUGF(level, msg,...)
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.