21.1 SDO_AGGR_CENTROID
Format
SDO_AGGR_CENTROID( AggregateGeometry SDOAGGRTYPE ) RETURN SDO_GEOMETRY;
Description
Returns a geometry object that is the centroid ("center of gravity") of the specified geometry objects.
Parameters
- AggregateGeometry
-
An object of type SDOAGGRTYPE (see SDOAGGRTYPE Object Type) that specifies the geometry column and dimensional array.
Usage Notes
The behavior of the function depends on whether the geometry objects are all polygons, all points, or a mixture of polygons and points:
-
If the geometry objects are all polygons, the centroid of all the objects is returned.
-
If the geometry objects are all points, the centroid of all the objects is returned.
-
If the geometry objects are a mixture of polygons and points (specifically, if they include at least one polygon and at least one point), any points are ignored, and the centroid of all the polygons is returned.
The result is weighted by the area of each polygon in the geometry objects. If the geometry objects are a mixture of polygons and points, the points are not used in the calculation of the centroid. If the geometry objects are all points, the points have equal weight.
See also the information about the SDO_GEOM.SDO_CENTROID function in SDO_GEOM Package (Geometry).
Examples
The following example returns the centroid of the geometry objects in the COLA_MARKETS table. (The example uses the definitions and data from Simple Example: Inserting_ Indexing_ and Querying Spatial Data.)
SELECT SDO_AGGR_CENTROID(SDOAGGRTYPE(shape, 0.005)) FROM cola_markets; SDO_AGGR_CENTROID(SDOAGGRTYPE(SHAPE,0.005))(SDO_GTYPE, SDO_SRID, SDO_POINT -------------------------------------------------------------------------------- SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(5.21295938, 5.00744233, NULL), NULL, NUL L)
Parent topic: Spatial Aggregate Functions