# Fix self-intersecting polygons merging overlapping areas

**856652**Oct 1, 2012 12:43 PM

Hi all,

I have a question about self-intersecting polygons with Oracle spatial.

In general it is recommended to have valid geometries so I need to fix those self-intersecting polygons. If I use the function SDO_UTIL.RECTIFY_GEOMETRY or if I use a self union (SDO_GEOM.SDO_UNION(geom, geom, 0.0f)), it creates a valid geometry but not the one I expect, because it cuts out the overlapping area. I want to have the overlapping area merged. Is there a way to achieve this with PL/sQL functions?

To get in more detail I have some examples. First the geometry with overlapping areas:

Regards,

Markus

I have a question about self-intersecting polygons with Oracle spatial.

In general it is recommended to have valid geometries so I need to fix those self-intersecting polygons. If I use the function SDO_UTIL.RECTIFY_GEOMETRY or if I use a self union (SDO_GEOM.SDO_UNION(geom, geom, 0.0f)), it creates a valid geometry but not the one I expect, because it cuts out the overlapping area. I want to have the overlapping area merged. Is there a way to achieve this with PL/sQL functions?

To get in more detail I have some examples. First the geometry with overlapping areas:

```
select
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 1),
SDO_ORDINATE_ARRAY(0,1, 4,1, 4,4, 1,4, 1,0, 2,0, 2,3, 3,3, 3,2, 0,2, 0,1)
)
from DUAL;
Result of this looks like a lanyard (# marks the polygon area where X marks the area which overlaps):
# # #
# #
# X # #
#
```

If I rectify this or create a self union, the overlapping area is cut out
```
select SDO_UTIL.RECTIFY_GEOMETRY(
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 1),
SDO_ORDINATE_ARRAY(0,1, 4,1, 4,4, 1,4, 1,0, 2,0, 2,3, 3,3, 3,2, 0,2, 0,1)
), 0.05)
from DUAL;
# # #
# #
# # #
#
```

What I need is a polygon that looks like this:
```
select
SDO_GEOMETRY(2007, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 1, 23, 2003, 1),
SDO_ORDINATE_ARRAY(0,1, 1,1, 1,0, 2,0, 2,1, 4,1, 4,4, 1,4, 1,2, 0,2, 0,1, 2,2, 2,3, 3,3, 3,2, 2,2)
)
from DUAL;
# # #
# #
# # # #
#
```

So my question here is there a function which is able to "rectify" it as I want?Regards,

Markus

I have the same question Show 0 Likes (0)