'How to get the area of a polygon explicitly written?

I'm trying to get the area of explicitly written polygon without any success.

SELECT SDO.GEOM.SDO_AREA('POLYGON ((...))')

... contains my polygon values

I'm getting error:

SQL Error [923] [42000]: ORA-00923: FROM keyword not found where expected

How can I write my polygon in the select query and get the area of this polygon ?



Solution 1:[1]

  • It is SDO_GEOM.SDO_AREA and not SDO.GEOM.SDO_AREA.
  • You need to pass a SDO_GEOMETRY object as the first argument and not a string (containing a GIS shape).
  • You need a second argument containing the tolerance (or a SDO_DIM_ARRAY).
  • You need a FROM clause and a table to select from (DUAL is usually used if you only want a single row).
  • You need to pass a valid GIS shape; ... is not valid.

Like this:

SELECT SDO_GEOM.SDO_AREA(
         SDO_GEOMETRY('POLYGON ((0 0, 0 1, 1 1, 1 0))'),
         0.0000000005
       )
FROM   DUAL;

db<>fiddle here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1