Copy one band from one raster to another.
Bands are duplicated from fromrast to torast using rt_band_duplicate. The caller will need to ensure that the copied band's data or path remains allocated for the lifetime of the copied bands.
- Parameters
-
| torast | : raster to copy band to |
| fromrast | : raster to copy band from |
| fromindex | : index of band in source raster, 0-based |
| toindex | : index of new band in destination raster, 0-based |
- Returns
- The band index of the second raster where the new band is copied. -1 if error
Definition at line 1276 of file rt_raster.c.
1279 {
1282
1283 assert(NULL != torast);
1284 assert(NULL != fromrast);
1285
1286
1288 rtwarn(
"rt_raster_copy_band: Attempting to add a band with different width or height");
1289 return -1;
1290 }
1291
1292
1294 rtwarn(
"rt_raster_copy_band: Second raster has no band");
1295 return -1;
1296 }
1297 else if (fromindex < 0) {
1298 rtwarn(
"rt_raster_copy_band: Band index for second raster < 0. Defaulted to 0");
1299 fromindex = 0;
1300 }
1301 else if (fromindex >= fromrast->
numBands) {
1302 rtwarn(
"rt_raster_copy_band: Band index for second raster > number of bands, truncated from %u to %u", fromindex, fromrast->
numBands - 1);
1303 fromindex = fromrast->
numBands - 1;
1304 }
1305
1306 if (toindex < 0) {
1307 rtwarn(
"rt_raster_copy_band: Band index for first raster < 0. Defaulted to 0");
1308 toindex = 0;
1309 }
1310 else if (toindex > torast->
numBands) {
1311 rtwarn(
"rt_raster_copy_band: Band index for first raster > number of bands, truncated from %u to %u", toindex, torast->
numBands);
1313 }
1314
1315
1317
1318
1320
1321
1323}
rt_band rt_band_duplicate(rt_band band)
Create a new band duplicated from source band.
void void void rtwarn(const char *fmt,...) __attribute__((format(printf
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
References rt_raster_t::height, rt_raster_t::numBands, rt_band_duplicate(), rt_raster_add_band(), rt_raster_get_band(), rtwarn(), and rt_raster_t::width.
Referenced by RASTER_addBandRasterArray(), RASTER_copyBand(), RASTER_mapAlgebraExpr(), RASTER_union_finalfn(), and rt_raster_from_band().