Select to view content in your preferred language

Get ST_GEOMETRY object's attribute

977
3
05-16-2022 12:09 PM
Bud
by
Esteemed Contributor

I have an SDE.ST_GEOMETRY value (Oracle 18c):

select
sde.st_geometry('LINESTRING EMPTY', 26917) as shape
from
dual

I want to select one of the ST_GEOMETRY object's attributes:

  • Entity
  • Numpts
  • Minx, miny, maxx, maxy
  • Area
  • Len
  • SRID
  • Points

How can I do that with Oracle SQL? 

0 Kudos
3 Replies
Bud
by
Esteemed Contributor

1. Use dot notation:

select
sde.st_geometry('LINESTRING EMPTY', 26917).len as shape
from
dual

If the shape column wasn't already wrapped in brackets via a function, then we would need to add the brackets:

select
    (shape).len
from
    my_fc


2. Or, use a table alias:

select
    a.shape.len
from
    my_fc a


3. Or, use the TREAT() function:

select
    treat(shape as sde.st_geometry).len
from
    my_fc

Although that might be misguided/unnecessary, since wrapping the column in brackets achieves the same thing (brackets is my preferred technique).

Bud
by
Esteemed Contributor

If I understand correctly, SDO_GEOMETRY has similar attributes. Additionally, SDO_GEOMETRY has methods (aka member functions):

  • Get_Dims
  • Get_GeoJson
  • Get_GType
  • Get_LRS_Dim
  • Get_WKB
  • Get_WKT
  • ST_CoordDim
  • ST_IsValid

Techniques for selecting an object's attribute

Replace value in SDO_ELEM_INFO_ARRAY varray

Modify SDO_ELEM_INFO_ARRAY of existing geometry

 

0 Kudos
Bud
by
Esteemed Contributor

For my notes, the result from an object's attribute can be different than the result from the corresponding ST_GEOMETRY function:

Why is (SHAPE).ENTITY different from SDE.ST_ENTITY(SHAPE)?

0 Kudos