0

The goal is to remove polygons with an intersection higher than a threshold, let's say 80% of the area from the smaller intersected polygon.

In the following picture we see in first image how the small red circle in coordinate (2.06, 41.41) is overlapping with two big circles, in this case in a percentage higher than 80% of its area. So the output will be the second image where the polygons remains under an smaller area of intersection than 80%.

enter image description here

For a reproducible example the data from the image is:

df = pd.DataFrame({"centroid":[geometry.Point(2.1990512195822394, 41.390164933230444), 
                               geometry.Point(2.1253931941117, 41.39962167422747), 
                               geometry.Point(2.0894753122714187, 41.41858536477601), 
                               geometry.Point(2.0724937348578973, 41.41460885909822), 
                               geometry.Point(2.0617756309327735, 41.42279161424217)],
                   "radius":[591.0368301703261,
                             247.41971532239666,
                             1978.0374093864489,
                             270.9246060416432,
                             1218.9034814954907],
                  }
                 )
PeCaDe
  • 277
  • 1
  • 8
  • 33

1 Answers1

1

For computing the intersection area, just do the following:

import matplotlib.pyplot as plt
from shapely.geometry.point import Point

test_circle = Point(1.7, 3).buffer(0.5)
other = Point(3, 4).buffer(2)

intersection = other.intersection(test_circle)

plt.axis("equal")
plt.plot(*test_circle.exterior.xy, c="r")
plt.plot(*other.exterior.xy, c="g")

if intersection.area > 0.8 * test_circle.area:
    # do stuff
    ...

then you just have to test the possible combinations of overlapping circles.

blunova
  • 2,122
  • 3
  • 9
  • 21
  • I understood the idea, I wanted to avoid loops, as originally I thought this approach. However I think in your proposal "other" object shouldnt be interescted with itself. – PeCaDe Aug 10 '22 at 13:26
  • sorry just edited, now it's fine, just a typo. – blunova Aug 10 '22 at 13:27