5.6 Statistical Operations
To apply statistical operations on one or more layers, which are from one or more GeoRaster objects, the following types of operations are available.
Parent topic: Raster Algebra and Analytics
5.6.1 On-the-Fly Statistical Analysis
Many applications require statistical analysis. GeoRaster provides statistical analysis functions that dynamically ("on the fly") compute complete statistical values for a GeoRaster object or the following individual statistical values: minimum, maximum, mean, median, mode, and standard deviation. You can do this without generating a histogram and updating the GeoRaster object metadata.
These subprograms support pyramids, band by band and the aggregation of specified band numbers. Each subprogram returns an SDO_NUMBER_ARRAY object or a number.
See the reference information for explanations and examples of these on-the-fly statistics computation subprograms:
These subprograms do not modify the metadata in the GeoRaster object, except for some formats of SDO_GEOR.generateStatistics that set statistical data in the GeoRaster object metadata and return a string value of TRUE
or FALSE
instead of an SDO_NUMBER_ARRAY object.
GeoRaster also provides statistical analysis functions that compute the area weighted statistical mean value for the cells and sub-cells within a specific window of the input GeoRaster object, and that calculate the three–dimensional (3D) surface area represented by digital elevation model (DEM) data that is stored in a GeoRaster object. See the reference information for explanations and examples of these on-the-fly statistics computation functions:
These two functions support irregular polygon clipping and sub-cell computation, thus providing very accurate results.
Parent topic: Statistical Operations
5.6.2 Stack Statistical Analysis
Stack statistical analysis generates a new one-layer GeoRaster object from one or more layers, which are from one or more GeoRaster objects, by computing one of the following statistical values for each cell: max, min, median, std, sum, minority, majority, or diversity.
To perform stack statistical analysis, you have the following options:
-
Use the SDO_GEOR_RA.stack procedure.
This option is more intuitive and does not require constructing raster algebra expressions (especially for GeoRaster objects with many layers), and it allows you to specify a list of layers instead of all layers.
-
Use the SDO_GEOR_RA.rasterMathOp procedure.
This option is more flexible and powerful, allowing you to perform more comlpicated statistical analysis.
Example 5-14 Using SDO_GEOR_RA.stack
This example uses the first option for performing stack statistical analysis. It calls the SDO_GEOR_RA.stack procedure to generate a new GeoRaster object by computing the maximum (max) value of layers 2 and 5 of two 3–layer source GeoRaster objects.
DECLARE
geor MDSYS.SDO_GEORASTER;
geor1 MDSYS.SDO_GEORASTER;
geor2 MDSYS.SDO_GEORASTER;
geom mdsys.sdo_geometry;
BEGIN
geom:= sdo_geometry(2003,82394, NULL,
sdo_elem_info_array(1, 1003, 1),
sdo_ordinate_array(20283.775, 1011087.9,
18783.775, 1008687.9,
21783.775, 1008687.9,
22683.775+0.001, 1009587.9+0.001,
20283.775, 1011087.9));
select georaster into geor from georaster_table where georid = 100;
select georaster into geor2 from georaster_table where georid = 102;
select georaster into geor1 from georaster_table where georid = 101 for update;
sdo_geor_ra.stack(SDO_GEORASTER_ARRAY(geor,geor2),geom,SDO_NUMBER_ARRAY(2,5),'max',null,geor1,'false',0,'TRUE');
update georaster_table set georaster = geor1 where georid = 101;
END;
/
PL/SQL procedure successfully completed.
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid=100;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(121, 66, 181)
1 row selected.
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid=102;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(33, 55, 56)
1 row selected.
-- In the results of the next SELECT statement, note:
-- max(181,56) ==> 181
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid =101;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(181)
1 row selected.
Example 5-15 Using SDO_GEOR_RA.rasterMathOp
This example uses the second option for performing stack statistical analysis. It calls the sdo_GEOR_RA.rasterMathOp specifying a statistical operation (max) to perform an operation similar to the preceding example, except that this example applies to all layers.
DECLARE
geor MDSYS.SDO_GEORASTER;
geor1 MDSYS.SDO_GEORASTER;
geor2 MDSYS.SDO_GEORASTER;
geo_array MDSYS.SDO_GEORASTER_ARRAY;
BEGIN
select georaster into geor from georaster_table where georid = 100;
select georaster into geor1 from georaster_table where georid = 101;
select georaster into geor2 from georaster_table where georid = 102 for update;
geo_array:=MDSYS.SDO_GEORASTER_ARRAY(geor,geor1);
sdo_geor_ra.rasterMathOp(geo_array,SDO_STRING2_ARRAY('max()'),null,geor2);
update georaster_table set georaster = geor2 where georid = 102;
commit;
END;
/
PL/SQL procedure successfully completed.
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid=100;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(181, 163, 159)
1 row selected.
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid=101;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(181, 122, 159) 1 row selected.
-- In the results of the next SELECT statement, note:
-- max(181,163,159,181,122,159) ==> 181
SELECT sdo_geor.getcellvalue(georaster,0,100,100,'') FROM georaster_table WHERE georid =102;
SDO_GEOR.GETCELLVALUE(GEORASTER,0,100,100,'')
--------------------------------------------------------------------------------
SDO_NUMBER_ARRAY(181)
1 row selected.
Parent topic: Statistical Operations