- Take 2 polygons.
- Overlay them.
- Get their intersection points.
- Renumber the points so that intersection points have the same ID value
- Determine the points that are inside and outside the other.
- Form sub-polygons which can be used for
- intersection
- clip
- symmetrical difference
- union
- concave hull
- and much much more
polygon A polygon B A over B



Now "intersect" and combine the geometries

looking easy so far, so produce a list of from-to point ids
polygon A polygon B
fr to i/o i/o fr to fr to
[[ 0, 3, -1, 1, 0, 7, 0, 3],
[ 3, 4, 0, -1, 7, 11, 3, 4],
[ 4, 6, -1, 1, 11, 17, 4, 6],
[ 6, 8, 1, -1, 17, 25, 6, 8],
[ 8, 9, 0, 1, 25, 34, 8, 9],
[ 9, 11, 1, -1, 34, 39, 9, 11],
[ 11, 15, 1, -1, 39, 51, 11, 15],
[ 15, 19, -1, 1, 51, 57, 15, 19],
[ 19, 0, 0, -1, 57, 0, 19, 0]])
Now, the first 3 columns belong to polygon A and they contain the segment from-to ids and whether the segment is
- inside (1),
- outside (-1) or
- on (0)
the other polygon.
Columns 3, 4 and 5 are the same for polyon B, but I just switched the i/o column so that both i/o columns were side by side.
The last 2 columns are columns 4 and 5, renumbered to match the common id values of polygon A.
Now the cool thing is, is that if the overlapping segments progress in a simple progressive pattern around the shapes, all the sub-shape components can be easily identified and obtained.

So can you see the components bits?
Of course, there is always a "corner-case" where the simplified rules break down the simple intersection rules don't count. That will be the subject of my next blog. But for now, many, many simple cases can be addressed. So for now numpy geometry at work