5.5 Classification Operations

Classification (segmentation) operations can be applied on source GeoRaster objects to generate new objects.

To apply simple classification operations on source GeoRaster objects and generate new GeoRaster objects based on your specifications, you can use the SDO_GEOR_RA.classify procedure and specify the expression, rangeArray, and valueArray parameters. This classification procedure is also called segmentation.

The expression parameter is used to compute values that are used to map into the value ranges defined in the rangeArray parameter. The rangeArray parameter specifies a number array that defines ranges for classifying cell values, and this array must have at least one element. The valueArray parameter is a number array that defines the target cell value for each range, and its length must be the length of rangeArray plus one.

Example 5-12 Classification

Example 5-12 calls the SDO_GEOR_RA.classify procedure to apply a segmentation operation on the value of the first band of the input GeoRaster object. The example assumes that the GeoRaster object is an image.

DECLARE
  geor       SDO_GEORASTER;
  geor1      SDO_GEORASTER;
  rangeArray SDO_NUMBER_ARRAY;
  valueArray SDO_NUMBER_ARRAY;
BEGIN
  rangeArray:=sdo_number_array(70,80,90,100,110,120,130,140,150,160,170,180);
  valueArray:=sdo_number_array(70,80,90,100,110,120,130,140,150,160,170,180,190);
  SELECT georaster INTO geor FROM georaster_table WHERE georid = 1;
  INSERT into georaster_table values (5, sdo_geor.init('rdt_1', 5)) returning georaster into geor1;
  sdo_geor_ra.classify(geor,'{0}',rangeArray,valueArray,null,geor1);
  UPDATE georaster_table SET georaster = geor1 WHERE georid = 5;
  COMMIT;
END;
/
 
PL/SQL procedure successfully completed.
 
-- In the next statement, the target value is 90 because the value of the
-- first band of source GeoRaster object is 88, which is between 80 and 90.
SELECT sdo_geor.getcellvalue(georaster,0,30,30,'') FROM georaster_table WHERE georid =1 OR georid =5 ORDER BY georid;

SDO_GEOR.GETCELLVALUE(GEORASTER,0,30,30,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(88, 136, 35)
SDO_NUMBER_ARRAY(90)
 
2 rows selected.
 
-- In the next statement, the target value is 190 because the value of the
-- first band of source GeoRaster object is 242, which is greater than 180.
SELECT sdo_geor.getcellvalue(georaster,0,132,116,'') FROM georaster_table WHERE georid =1 OR georid =5 ORDER BY georid;

SDO_GEOR.GETCELLVALUE(GEORASTER,0,132,116,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(242, 225, 233)
SDO_NUMBER_ARRAY(190)
 
2 rows selected.

Example 5-13 Classification with nodata and nodataValue Parameters

Example 5-13 calls the SDO_GEOR_RA.classify procedure to apply a segmentation operation on the value of the first layer of the source GeoRaster object, and to set the nodata parameter to 'TRUE' and the nodataValue parameter to 5, so that all NODATA pixels will be set with a NODATA value of 5 in the target GeoRaster object.

DECLARE
  geor       SDO_GEORASTER;
  geor1      SDO_GEORASTER;
  rangeArray SDO_NUMEBR_ARRAY;
  valueArray SDO_NUMEBR_ARRAY;
BEGIN
  rangeArray:=sdo_number_array(70,80,90,100,110,120,130,140,150,160,170,180);
  valueArray:=sdo_number_array(70,80,90,100,110,120,130,140,150,160,170,180,190);
  SELECT georaster INTO geor FROM georaster_table WHERE georid = 1;
  sdo_geor.addNODATA(geor, 2,136);
  INSERT into georaster_table values (5, sdo_geor.init('rdt_1', 5)) returning georaster into geor1;
  sdo_geor_ra.classify(geor,'{0}',rangeArray,valueArray,null,geor1,'true',5);
  UPDATE georaster_table SET georaster = geor1 WHERE georid = 5;
END;
/
 
PL/SQL procedure successfully completed.
 
-- In the next statement, the target value of the cell is 5 because the value
-- of the second layer of the input GeoRaster object is 136, which is nodata.
SELECT sdo_geor.getcellvalue(georaster,0,30,30,'') FROM georaster_table WHERE georid =1 OR georid =5 ORDER BY georid;

SDO_GEOR.GETCELLVALUE(GEORASTER,0,30,30,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(88, 136, 35)
SDO_NUMBER_ARRAY(5)
 
2 rows selected.