Unix Technical Forum

Spatial: Make line out of (many) points

This is a discussion on Spatial: Make line out of (many) points within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hello! I am struggling with Oracle Spatial (10.2.0.1.0 on Win2003). Maybe somebody here can halp me. I have a ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:16 AM
Benjamin Hell
 
Posts: n/a
Default Spatial: Make line out of (many) points

Hello!

I am struggling with Oracle Spatial (10.2.0.1.0 on Win2003). Maybe
somebody here can halp me. I have a table "SOUNDING" containing rows
with (essentially) point IDs "PID" and point geometries "GEOMETRY"
(SDO_GTYPE = 3001):

> DESCR SOUNDING;

Name
--------------------------------
PID NUMBER(12)
DATASETID VARCHAR2(16)
GEOMETRY MDSYS.SDO_GEOMETRY

A sample point looks like this:

GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
----------------------------------------------------------------
SDO_GEOMETRY(3001, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(-70.0213, 40.44136, -267.0))

The points represent samples ordered along a measurement line.

Furthermore I have a table "DATASET" containing ID "DATASETID"
(referenced by SOUNDING.DATASETID) and a geometry attribute:

> DESCR DATASET;

Name
--------------------------------
DATASETID VARCHAR2(16)
LINEGEOMETRY MDSYS.SDO_GEOMETRY

Now, what I want to do: I need the measurement line as a line
geometry (SDO_GTYPE = 3002) and tried to find out what query to use
for translating the point geometries into a line along these points.
I could think of two ways: (1) adding the coordinates of each point
to the end of a line with SDO_UTIL.APPEND() directly after inserting
that point. Problem with that is that as the line grows (longer than
some 1000 points), SDO_UTIL.APPEND() gets _really_ slow. (2) First
inserting all the point geometries and then merging them with
SDO_AGGR_UNION(). This is the closest I could get:

UPDATE DATASET
SET LINEGEOMETRY = (
SELECT SDO_AGGR_UNION(SDOAGGRTYPE(GEOMETRY, 0.0001))
FROM (
SELECT GEOMETRY
FROM SOUNDING
WHERE DATASETID = 'NGDCA2075L01'
ORDER BY PID
)
)
WHERE DATASETID = 'NGDCA2075L01';

This is really fast. Problem with (2): SDO_AGGR_UNION() outputs the
point succession in arbitrary order, not ordered by PID as I need it
(I know that it performs a union operation and not a concatenation,
and that the ORDER BY PID is essentially useless here).

I'm sure there is another way to do a real concatenation than (1) -
I just don't find it. Anybody out there who can help?


Thanks a lot!

Benjamin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:16 AM
Benjamin Hell
 
Posts: n/a
Default Re: Spatial: Make line out of (many) points

Hello again!

I forgot something. Minor update...

Benjamin Hell wrote:
> (2) First
> inserting all the point geometries and then merging them with
> SDO_AGGR_UNION(). This is the closest I could get:
>
> UPDATE DATASET
> SET LINEGEOMETRY = (
> SELECT SDO_AGGR_UNION(SDOAGGRTYPE(GEOMETRY, 0.0001))
> FROM (
> SELECT GEOMETRY
> FROM SOUNDING
> WHERE DATASETID = 'NGDCA2075L01'
> ORDER BY PID
> )
> )
> WHERE DATASETID = 'NGDCA2075L01';


To get a line geometry instead of a multipoint something, I manually
change SDO_GTYPE and SDO_ELEM_INFO afterwards:

UPDATE DATASET D
SET D.SIMPLEGEOMETRY.SDO_GTYPE = 3002,
D.SIMPLEGEOMETRY.SDO_ELEM_INFO =
SDO_ELEM_INFO_ARRAY(1, 2, 1)
WHERE D.DATASETID = 'NGDCA2075L01';


Regards,

Benjamin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 10:19 AM
Volker Hetzer
 
Posts: n/a
Default Re: Spatial: Make line out of (many) points

If I were you I'd probably do a little PL/SQL function
which gets the points in the right order, assembles
info and ordinate arrays and returns a geometry object.

insert into lines select linefunction(x.datasetid) from (select distinct datasetid ...) x;

or so.

If you are good at it, you could even do an aggregate function
for this.

Lots of Greetings!
Volker
--
For email replies, please substitute the obvious.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:37 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com