6.15 Band Merging

For image classification, time series analysis, and raster GIS modeling, multiple bands or layers of different GeoRaster objects may need to be merged into a single GeoRaster object.

This operation is called band or layer merging in GeoRaster, and can be performed by using the SDO_GEOR.mergeLayers procedure or the SDO_GEOR_RA.rasterMathOp procedure. You can either append specified bands of a source GeoRaster object to a target GeoRaster object or merge different bands from two GeoRaster objects into a new GeoRaster object. By doing this merging or appending iteratively, you can merge an unlimited number of bands into a single GeoRaster object.

Example 6-16 Band Merging

Example 6-16 includes two examples. The first example assumes there are eight GeoRaster objects, each of which contains only one band loaded from a single-band Landsat ETM+ image file in GeoTIFF format. The number of the band in each GeoRaster object is the same as the GEORID column value for the GeoRaster object. The example merges all bands into a single GeoRaster object to create a complete ETM+ scene.

DECLARE
    gr1 sdo_georaster;
BEGIN
    select georaster into gr1 from georaster_table where georid = 1 for update;
    for rec in (select georaster from georaster_table 
                     where georid >= 2 and georid <= 8 
                     order by georid)
    loop
       sdo_geor.mergelayers(gr1, rec.georaster);
    end loop;
    update georaster_table set georaster = gr1 where georid = 1;
    commit;
END;
/

The second example assumes there are eight GeoRaster objects, each of which contains three bands. The example picks up one band from each GeoRaster object and merges them into a single 8-band GeoRaster object in parallel.

DECLARE
  geor       SDO_GEORASTER;
  geo_array  SDO_GEORASTER_ARRAY;
BEGIN
  SELECT georaster INTO geor FROM georaster_table WHERE georid = 0 for update;
  geo_array:=SDO_GEORASTER_ARRAY();
  for rec in (select georaster from georaster_table 
                     where georid >= 1 and georid <= 8 
                     order by georid)
  loop
     geo_array.extend(1);
     geo_array(geo_array.last):=rec.georaster;
  end loop;
  sdo_geor_ra.rasterMathOp(geo_array,SDO_STRING2_ARRAY('{0,0}','{1,1}','{2,2}','{3,0}','{4,1}','{5,2}','{6,0}','{7,1}',),null,geor,'false',null,'parallel=4');
  UPDATE georaster_table SET georaster = geor WHERE georid = 0;
  COMMIT;
END;
/