Select to view content in your preferred language

Polygon Intersections

132
0
a month ago
Labels (1)
DanPatterson
MVP Esteemed Contributor
5 0 132
  • 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

edgy1.pngeclip.pngedgy1_eclip.png

 

 

 

 

 

Now "intersect" and combine the geometries

edgy1_eclip0.png

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.

final.png

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 

Tags (3)
About the Author
Retired Geomatics Instructor (also DanPatterson_Retired). Currently working on geometry projects (various) as they relate to GIS and spatial analysis. I use NumPy, python and kin and interface with ArcGIS Pro.
Labels