4

I need to remove any overlapping from these two polygons poliA and poliB when I run

select geometry(ST_Difference(poliA::geometry, poliB::geometry)) 

apparently returns A-B but, if I use ST_Intersection to look for any overlapping area it's returning a line that matches with part of the border where both polygons collide.

select geometry (ST_Intersection( (select geometry(ST_Difference(poliA::geometry, poliB::geometry))),poliB::geometry)

blue line is the overlap

I even tried to remove it using Arcgis Pro altering the xy tolerance but can't get rid of overlapping lines and dots, and ST_Difference is not doing better

2
  • 1
    I'm thinking about using a negative buffer for the polygons and afterwards buffering them again with the same postive value again. Would that work? Commented Jan 22, 2022 at 7:19
  • I need to preserve the shape of polygon A
    – Kashtanka
    Commented Jan 23, 2022 at 18:12

2 Answers 2

6

This behaviour is expected. If two polygons are adjacent they intersect.

These four grid squares does not overlap, the result of their intersection can be a linestring:

select st_intersection(t1.geom, t2.geom)
from public.grid4 t1
join
public.grid4 t2
on st_intersects(t1.geom, t2.geom)
where t1.id=1 and t2.id=2

enter image description here Or a point

enter image description here

Check if they overlap with st_overlaps, they dont:

select *
from public.grid4 t1
join
public.grid4 t2
on st_overlaps(t1.geom, t2.geom)
where t1.id=1 and t2.id=2

enter image description here

If you for some reason want to use intersects you can limit the result by st_area or st_dimension:

select  t1.id, 
        t2.id, 
        st_astext(st_intersection(t1.geom, t2.geom)), 
        st_area(st_intersection(t1.geom, t2.geom)), 
        st_dimension(st_intersection(t1.geom, t2.geom))
from newgrid t1
join newgrid t2
on st_intersects(t1.geom, t2.geom)
where t1.id < t2.id
--and st_area(st_intersection(t1.geom, t2.geom))>100
--and st_dimension(st_intersection(t1.geom, t2.geom))=2

enter image description here

2
  • st_overlaps returns true since there's the line I shown on the pic. what I'm trying to do is to get A without this line that overlaps with polygon B
    – Kashtanka
    Commented Jan 23, 2022 at 4:03
  • If it is a line you can filter it by using st_dimension
    – Bera
    Commented Jan 24, 2022 at 13:00
2

The only way I found to solve the problem was using the Reshape tool from Arcgis Pro (Edition module) to cut manually all the overlapping segments. Leaving this comment here in case somebody sees him/herself in this situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.