5.8 Raster Data Scaling and Offsetting

You can perform raster data scaling and offsetting operations.

Raster algebra has many applications, such as cartographic modeling (see Cartographic Modeling), vegetation index computing (see Vegetation Index Computation), and tasseled cap transformation (see Tasseled Cap Transformation). Topics in this chapter and in Image Processing and Virtual Mosaic describe a few sample applications of the GeoRaster raster algebra.

Example 5-20 Converting DEM Data from Feet to Meters

The cell value of a GeoRaster object may represent a quantitative attribute of spatial objects, which could be in a specific unit. For example, the elevation data in a DEM GeoRaster object could be in the unit of feet. An application may require you to convert the elevations into another unit, such as meters, for georectification and other operations. You can use the raster algebra to scale the DEM data from feet into meters (that is, unit conversion), as shown in Example 5-20.

DECLARE 
  geor1    SDO_GEORASTER;
  geor2    SDO_GEORASTER;
BEGIN
  --Source GeoRaster object with a single DEM layer
  select georaster into geor1 from georaster_table where georid = 1;
  --To store the output DEM layer
  select georaster into geor2 from georaster_table where georid = 2 for update;
  --Scale elevation from feet to meters using the unit factor
  sdo_geor_ra.rasterMathOp(geor1,SDO_STRING2_ARRAY('{0} * 0.3048'),null,geor2);
  --Commit changes to the output georaster object
  update georaster_table set georaster = geor2 where georid = 2;
  commit;
END;
/

Example 5-21 Offsetting DEM by Geoid Height

The cell data of a GeoRaster object may need to be offset by a constant for further processing. For example, a DEM layer may represent orthometric elevation instead of ellipsoidal elevation. To orthorectify a raw image georeferenced by an RPC model requires ellipsoidal elevation. Example 5-21 offsets the orthometric DEM by the geoid height, resulting in an ellipsoidal DEM.

DECLARE 
  geor1    SDO_GEORASTER;
  geor2    SDO_GEORASTER;
BEGIN
  --Source GeoRaster object with a single orthometric DEM layer
  select georaster into geor1 from georaster_table where georid = 1;
  --To store the output DEM layer
  select georaster into geor2 from georaster_table where georid = 2 for update;
  --Offset elevation by geoid height to get ellipsoidal elevation
  sdo_geor_ra.rasterMathOp(geor1,SDO_STRING2_ARRAY('{0} - 28.8'),null,geor2);
  --Commit changes to the output GeoRaster object
  update georaster_table set georaster = geor2 where georid = 2;
  commit;
END;
/

Example 5-22 Converting (Scaling) and Offsetting

You can combine the operations of Example 5-20 and Example 5-21 into a single simple step, as shown in Example 5-22.

DECLARE 
  geor1    SDO_GEORASTER;
  geor2    SDO_GEORASTER;
BEGIN
  --Source GeoRaster object with a single DEM layer
  select georaster into geor1 from georaster_table where georid = 1;
  --To store the output DEM layer
  select georaster into geor2 from georaster_table where georid = 2 for update;
  --Scale elevation from feet to meters and offset elevation by geoid height
  sdo_geor_ra.rasterMathOp(geor1,SDO_STRING2_ARRAY('{0} * 0.3048 - 28.8'),null,geor2);
  --Commit changes to the output georaster object
  update georaster_table set georaster = geor2 where georid = 2;
  commit;
END;
/