I have two overlapping shapely polygons A and B. I want to divide their intersection into two pieces, such that one part of the intersection is the set of points in A.intersection(B) (or symmetrically, B.intersection(A) to the boundary of A-B, and the other is the set of points closer to the boundary of B-A.

Is there an way to do this in shapely other than applying a brute-force mesh and checking the distance to each polygon's boundary?

  • when you say set of points, do you mean to find the points of A that are inside of B??
    – rickD
    Commented Jul 13, 2017 at 21:49
  • seems like .intersection() or .difference() method would be the place to start anyway
    – rickD
    Commented Jul 13, 2017 at 21:55
  • Thanks, @rickD, I clarified the question a little; yes, I'm talking about the points in the intersection of A and B, or the points of A inside B.
    – Michael K
    Commented Jul 13, 2017 at 21:58
  • You can convert the Intersection to Points, Polygons A,B to lines. The normal Shapely Intersection should work to separate the Intersection Points by source polygon, eg, Intersection_pts.intersect(line_A)
    – klewis
    Commented Jul 13, 2017 at 22:54
  • Right, but they won't be disjoint, I believe; I'm trying to partition the intersection between the two intersecting polygons exactly.
    – Michael K
    Commented Jul 13, 2017 at 22:56


Browse other questions tagged or ask your own question.