Search code examples
oracleclippolygonsoracle-spatial

Clipping a polygon in Oracle


I have a polygon in table 2 with its id, no and geometry. In table 1 I have polygons with the same fields. The polygon in table2 in intersects with a few polygons from table 1.What I am trying to do is clip of the polygons which overlap polygon from table 2 and insert the same fields and geometry in table 3. So if polygon from table 2 has 2 overlaps I want to get rid of those overlaps and just get the rest into a new table.The following code is for returning the clipped part of the geometry .How do I get the geometry for the polygon after the clipping is done.

insert into table 3  
select a.store_id,b.store_id,a.store_number,a.client_id,sdo_geom.sdo_intersection(b.geometry,a.geometry,0.005)  
from table_1 a, table_2 b  
where b.store_id=34746  
and sdo_anyinteract(b.geometry,a.geometry)='True';  

Solution

  • Instead of using sdo_geom.sdo_intersection, you probably want to use sdo_geom.sdo_difference - this acts as a minus operation:

    enter image description here