5 Replies Latest reply on Oct 8, 2013 10:14 PM by user1105585

# Line with intersection points across Polygon

I have a (multi point) line that intersects a polygon and I can find the intersection points

See this site for example:  Finding Intersection Points between Line and&amp;#160;Polygon

However I would like to get the original multi point line WITH the intersection points added...

How would I achieve this?

Basically for a given line that intersects a polygon,  I would like to have returned...

a new line that consists of  the original points AND the intersection points

Thanks in advance

• ###### 1. Re: Line with intersection points across Polygon

Hi

If understand you correctly, you want to add the intersection "vertices" explictly to your line geometry, is that correct?

If so you can do this by using sdo_geom.sdo_union(your_line_geometry, 'resulting_points_from_the_intersction_result_line_and_polygon')).

(note: Could not think off immediate risks on invalid geometries, maybe there are).

Luc

• ###### 2. Re: Line with intersection points across Polygon

Hi Luc,

Thanks for your response.

I had tried an SDO_UNION however the result of the union is not quite what I expected...

Here is an example,

The union below is my original multi point LINE and the 2nd are the "intersections" that I have previously calculated...

These intersections are actually in between specific points in the LINE...

However the union does not seem to put these 4 points in the line where I expect them too..

Not sure if SDO_UNION is the function for the job ?

or am I doing something incorrect (likely)

For the 2nd geometry (which has the intersection points).... what would be a type to use ?  Its not a LINE its

really a collection of points which "fall on" or touch that LINE.

select SDO_GEOM.SDO_UNION (

(SELECT SDO_GEOMETRY(2002, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(

-73.7789255556,40.6397511111,-70.0267102778,41.2818872223,-69.7833,42.4333,-69.6333,42.5166,-69.45,42.6166,-69.3,42.7,-69.1333,42.8,-68.95,42.8833,-68.8,42.9833,-68.6333,43.6666,-68.45,43.1666,-68.2666,43.25,-68.1,43.3333,-67.9166,43.4333,-67.7666,43.5166,-67.5833,43.6,-67.3833,43.7,-67.2166,43.7833,-67.6666,43.8833,-66.8666,43.9666,-66.65,44.6666,-66.5,44.15,-66.2833,44.2333,-66.1,44.3166,-65.9166,44.4333,-65.7333,44.5166,-65.55,44.6,-65.3666,44.6833,-65.1666,44.7666,-64.9833,44.85,-64.7833,44.95,-64.5833,45.3333,-64.4,45.1166,-64.1833,45.2166,-64,45.3,-63.8,45.3833,-63.6166,45.4833,-63.4166,45.5666,-63.2,45.65,-63,45.7333,-62.8166,45.8333,-62.6166,45.9166,-62.4166,46,-62.2,46.3333,-62,46.1666,-61.7833,46.25,-61.5833,46.35,-61.3833,46.4166,-61.1833,46.5,-60.9833,46.5833,-60.7666,46.6666,-60.5666,46.75,-60.3666,46.8166,-60.15,46.9,-59.95,46.9833,-59.75,47.6666,-59.55,47.15,-59.35,47.2166,-59.1166,47.3,-58.9333,47.3666,-58.7333,47.4333,-58.5166,47.5166,-58.3333,47.5833,-58.1333,47.6666,-57.9166,47.7333,-57.7166,47.8,-57.55,47.8666,-57.3333,47.95,-57.1333,48.6666,-56.9333,48.3333,-56.7166,48.15,-56.5166,48.2333,-56.3,48.2833,-56.1166,48.3666,-55.8833,48.4166,-55.7,48.4833,-55.4666,48.55,-55.2833,48.6,-55.05,48.6666,-54.8666,48.7166,-54.65,48.7666,-54.45,48.85,-54.2333,48.9,-54.6666,48.95,-53.8,49.6666,-53.6,49.6666,-53.3833,49.1333,-53.1833,49.1833,-52.9833,49.2333,-52.7666,49.3,-52.55,49.35,-52.3333,49.4,-52.1166,49.45,-51.9,49.5166,-51.6833,49.5666,-51.4666,49.6166,-51.2333,49.6666,-51.6666,49.7166,-50.8,49.75,-50.6,49.8166,-50.3833,49.8666,-50.1666,49.9166,-49.95,49.9666,-49.7333,50,-49.5166,50.3333,-49.2666,50.6666,-49.05,50.3333,-48.8333,50.1166,-48.5833,50.15,-47.9166,50.25,-40,51,-35,51.6,-29,51.1166666667,-40.0833333333,50.4333333333,-44.55,49.6,-52.75,47.6166666667,-52.7524194444,47.6186194445

)) AS geom

FROM dual

),     -- LINE

(SELECT SDO_GEOMETRY(2005, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(

-50.0000000000001,49.9551029915852,

-30,51.2193352796549,

-50,48.3647769601594,

-30,51.0986671679795

)) AS geom2

FROM dual

), --  INTERSECTIONS

0.005

) from dual;

The "INTERSECTIONS" above

-50.0000000000001,49.9551029915852,

-30,51.2193352796549,

-50,48.3647769601594,

-30,51.0986671679795

I expect these points above to be placed in between

[Lat: 49.9166, Long: -50.1666] -->    crossing Lat: 49.9551029915853, Long: -50  <--   [Lat: 49.9666, Long: -49.95]

[Lat: 51.6, Long: -35] -->                 crossing Lat: 51.2193352796549, Long: -30  <--   [Lat: 51.1166666667, Long: -29]

[Lat: 51.1166666667, Long: -29] --> crossing Lat: 51.0986671679795, Long: -30  <--   [Lat: 50.4333333333, Long: -40.0833333333]

[Lat: 49.6, Long: -44.55] -->             crossing Lat: 48.3647769601594, Long: -50  <--  [Lat: 47.6166666667, Long: -52.75]

I have the intersections which is fine.. but I'd like them to be all aggregated into the original LINE

or if there is a way to get the points in the line that are between these intersections

Thanks for your help

Cheers

• ###### 3. Re: Line with intersection points across Polygon

Where did you got the intersecting geometry from?

The sdo_elem_info array does not match your multipoint 2005 definition, I believe.

This should be SDO_ELEM_INFO_ARRAY(1,1,1, 3,1,1, 5,1,1, 7,1,1) instead of (1,2,1).

Then the result union geom is a 2002 line a opposed to your example which returns a  2006 collection.

And you will see that those points are where you expect them to be. (on test 11R2)

Luc

• ###### 4. Re: Line with intersection points across Polygon

If you are putting the intersection result together yourself you could be easier of using a point cluster definition.

a 2005 sdo_gtype with SDO_ELEM_INFO_ARRAY (1,1,n), with n being the number of points in your 'point cluster' (or multipoint).

Luc

• ###### 5. Re: Line with intersection points across Polygon

Thanks Luc,

That worked, bad copy / paste

Thanks again!