Skip to content
Advertisement

Get XY coordinates from GEOM_SEGMENT_START_PT() output

Oracle 18c:

How can I get the X & Y coordinates from GEOM_SEGMENT_START_PT()‘s resulting LRS point?

select
  sdo_lrs.geom_segment_start_pt(sdo_geometry('linestring(1 2, 3 4, 5 6)'))
from
  dual

SDO_LRS.GEOM_SEGMENT_START_PT(SDO_GEOMETRY('LINESTRING(12,34,56)')) 
---------------------------------------------------
SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(1,2))

Note: The coordinates are stored in the SDO_ORDINATE_ARRAY( ), not the SDO_POINT.

Desired output:

 X  Y
-- --
 1  2

Normally, I’d use something like a.shape.sdo_point.x. But I don’t think that applies here since the coordinates aren’t stored in the SDO_POINT.

Related: Oracle Spatial Community – Get X & Y coordinates from GEOM_SEGMENT_START_PT()

Advertisement

Answer

Use the below SQL for getting X and Y coordinates

    select 
      t.X, 
      t.Y 
    from 
      TABLE(
        SDO_UTIL.GETVERTICES(
          sdo_lrs.geom_segment_start_pt(
            sdo_geometry('linestring(1 2, 3 4, 5 6)')
          )
        )
      ) t;
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement