Question

A polygon in terms of oracle spatial data (SDO_GEOMETRY). The polygon is formed by geographic coordinates and can be irregular.

Was it helpful?

Solution

The below function return the area of the GEOMETRY also it works with any polygon including polygons with holes.

SELECT SDO_GEOM.SDO_AREA(<geometry_column_name>, <tolerance_value>) 
FROM   <table_name>;

Where TOLERANCE_VALUE is used to associate a level of precision with spatial data. Refer here for more in detail.

OTHER TIPS

In addition you can specify the unit in which the result should be returned:

select state, county, sdo_geom.sdo_area(geom, 0.005, 'unit=sq_mile')
from us_counties;

returns the area in square miles. When you do not specify any unit, the result will be in square meters if the geometries are in geodetic coordinates, in the square of the distance unit for the coordinate system when they are projected. This is generally square meters too since most projections are in meters (but not all: some US projections are in feet).

I recommend always specifying an explicit unit, even if you want square meters. This makes your code more readable and lifts any ambiguities.

You can find the available area units here:

select distinct short_name, unit_of_meas_name 
from sdo_units_of_measure 
where unit_of_meas_type = 'area'; 

which returns

SHORT_NAME           UNIT_OF_MEAS_NAME
-------------------- ------------------------------
ACRE                 Acre
HECTARE              Hectare
PERCH                Perch
ROOD                 Rood
SQ_KM                Square Kilometer
SQ_KILOMETER         Square Kilometer
SQ_M                 Square Meter
SQ_METER             Square Meter
SQ_CM                Square Centimeter
SQ_CENTIMETER        Square Centimeter
SQ_MM                Square Millimeter
SQ_MILLIMETER        Square Millimeter
SQ_MILE              Square Mile
SQ_FT                Square Foot
SQ_FOOT              Square Foot
SQ_IN                Square Inch
SQ_INCH              Square Inch
SQ_YARD              Square Yard
SQ_CH                Square Chain
SQ_CHAIN             Square Chain
SQ_LI                Square Link
SQ_LINK              Square Link
SQ_ROD               Square Rod
SQ_SURVEY_FOOT       Square Survey Feet
USER-SQ-HALF-METER   USER-SQ-HALF-METER

25 rows selected.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top