<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Polygons Intersection Points in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540985#M42275</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually i don't understand how your point in polygon code helps me, you need to tell, what is problem in my code. ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Dec 2014 10:16:28 GMT</pubDate>
    <dc:creator>AhsanAbbas</dc:creator>
    <dc:date>2014-12-24T10:16:28Z</dc:date>
    <item>
      <title>Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540981#M42271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to calculate the intersection point of two polygon, the polygons are illustrate in picture. The picture clearly show that there are two points&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14.4444446563721px;"&gt;of intersections.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have write some code, but there is problem init, it's calculate more than two intersection point. Blow is my code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def linesIntersection(A, B, C, D):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = A[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1 = A[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x2 = B[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2 = B[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x3 = C[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y3 = C[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x4 = D[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y4 = D[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print x1, y1, x2, y2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print x3, y3, x4, y4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; denomenator = (((x1-x2)*(y3-y4)) - ((y1-y2)*(x3-x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if denomenator == 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P1 = (((x1*y2 - y1*x2)*(x3-x4)) - ((x1-x2)*(x3*y4-y3*x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Px = P1 / denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P2 = (((x1*y2 - y1*x2)*(y3-y4)) - ((y1-y2)*(x3*y4-y3*x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Py = P2 / denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "The Intersection points are: ", Px, Py&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;polygon1 = [(1,0),(3,0),(3,2),(1,2),(1,0)]&lt;/P&gt;&lt;P&gt;polygon2 = [(0,1),(2,1),(2,3),(0,3),(0,1)]&lt;/P&gt;&lt;P&gt;poly1 = len(polygon1)&lt;/P&gt;&lt;P&gt;poly2 = len(polygon1)&lt;/P&gt;&lt;P&gt;#print poly1,poly2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i in range(poly1-1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A = polygon1&lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B = polygon1[i+1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in range(poly2-1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C = polygon2&lt;J&gt;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D = polygon2[j+1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linesIntersection(A, B, C, D)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using determinant for calculating the intersection of point. &lt;A href="http://en.wikipedia.org/wiki/Line%E2%80%93line_intersection"&gt;http://en.wikipedia.org/wiki/Line%E2%80%93line_intersection&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There is a condition both lines should be similar planes, this is where problem begin, i don't know how to do it ? Pleas help me...&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/cry.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/43385_Capture.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 18:04:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540981#M42271</guid>
      <dc:creator>AhsanAbbas</dc:creator>
      <dc:date>2014-12-23T18:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540982#M42272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are more than one line intersections...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why don't you try this demo script I use for education purposes...it uses "ray-casting"&amp;nbsp; It will give you some ideas, so it is quite verbose.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
PointInPolygonRayCasting.py
&amp;nbsp; Determine if a point is inside a given polygon or not
&amp;nbsp; Polygon is a list of [x,y] pairs, either as a list or tuple.
&amp;nbsp; A quick check is made to see if the pnt is one of the polygon's forming
&amp;nbsp; pnts.&amp;nbsp; Points that form a polygon are considered inside.&amp;nbsp; 
&amp;nbsp; More complex analysis would check to see whether pnt, intersects the lines formed
&amp;nbsp; by the polygon points.
&amp;nbsp; 
&amp;nbsp; This fuction returns True or False.&amp;nbsp; The algorithm is called
&amp;nbsp; "Ray Casting Method".
'''
def point_in_poly(pnt, poly, epsilon):
&amp;nbsp; '''Point in Polygon test using the Ray Casting Method.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = [x, y]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poly = a list of pnts in clockwise order and the first and last are the same
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; epsilon = the absolute value of the deviation to be considered if a point is
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; within a polygon.&amp;nbsp; A small value such as 1e9 should suffice considering
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; that is being used with real world coordinates.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sources: various but &lt;A href="http://paulbourke.net/geometry/insidepoly/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://paulbourke.net/geometry/insidepoly/&lt;/A&gt;&amp;nbsp; or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://geospatialpython.com/2011_01_01_archive.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://geospatialpython.com/2011_01_01_archive.html&lt;/A&gt; are good
&amp;nbsp; '''
&amp;nbsp; n = len(poly)
&amp;nbsp; inside = False
&amp;nbsp; x, y = pnt
&amp;nbsp; p1_X, p1_Y = poly[0]
&amp;nbsp; p2_X, p2_Y = poly[1]
&amp;nbsp; if pnt in poly:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Step 1 quick check to see if a pnt is one of the polygon pnts.
&amp;nbsp;&amp;nbsp;&amp;nbsp; p1_X, p1_Y = p2_X, p2_Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp; else:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Step 2&amp;nbsp; check for obvious cases as to whether points inside or outside
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(n + 1):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p2_X, p2_Y = poly[i % n]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if y &amp;gt; min(p1_Y, p2_Y):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if y &amp;lt;= max(p1_Y, p2_Y):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x &amp;lt;= max(p1_X, p2_X):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if p1_Y != p2_Y:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x_intercept = (y - p1_Y)*(p2_X - p1_X)/(p2_Y - p1_Y) + p1_X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "x_intercept: ", x_intercept
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inside = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return inside
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if p1_X == p2_X or x &amp;lt;= x_intercept:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inside = not inside
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p1_X, p1_Y = p2_X, p2_Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; return inside
if __name__ == "__main__":
&amp;nbsp; ''' Test
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Note point on boundary fails ie (0,10), floats don't matter
&amp;nbsp; '''
&amp;nbsp; polygon = [[0.0,0.0],[0.0,10.0],[10.0,10.0],[10.0,0.0],[0.0,0.0]]
&amp;nbsp; print "\nPoint in Polygon testing:&amp;nbsp; Note, points on boundary are not considered inside"
&amp;nbsp; print "\nPolygon boundary: ", polygon
&amp;nbsp; pnts = [[0,0],[0.001,0], [0.001,0.001],[1,5], [-10,-10],[9.9999999,9.9999999]]
&amp;nbsp; for pnt in pnts:## Call the fuction with the points and the polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "point: ", pnt, " in polygon? ", point_in_poly(pnt, polygon, 1e-9)



&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540982#M42272</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T23:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540983#M42273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a silly thought... since we are at the GeoNet (ArcGIS) forum and talking about python code, why don't we use some arcpy "magic"...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
lst_pol1 = [(1,0),(3,0),(3,2),(1,2),(1,0)]
lst_pol2 = [(0,1),(2,1),(2,3),(0,3),(0,1)]

polygon1 = arcpy.Polygon(arcpy.Array([arcpy.Point(a[0],a[1]) for a in lst_pol1]))
polygon2 = arcpy.Polygon(arcpy.Array([arcpy.Point(a[0],a[1]) for a in lst_pol2]))

dimension = 1
pnts = polygon1.intersect(polygon2, dimension)
for pnt in pnts:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pnt&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;2,0001220703125 2,0001220703125 NaN NaN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;1,0001220703125 1,0001220703125 NaN NaN&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:28:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540983#M42273</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T23:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540984#M42274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;his previous posts Xander suggest that he wanted pure python implementations and not the useful "magic" shortcuts &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; left out numpy implementation for the moment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps ... make sure you specify a spatial reference for the points while being accessed otherwise the results are not cast in the appropriate precision (I posted a number of threads on this issue and it has been seen by others).&amp;nbsp; It can affect some results like intersections etc when the geometries are close to within numeric precision.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 00:36:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540984#M42274</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-12-24T00:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540985#M42275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually i don't understand how your point in polygon code helps me, you need to tell, what is problem in my code. ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 10:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540985#M42275</guid>
      <dc:creator>AhsanAbbas</dc:creator>
      <dc:date>2014-12-24T10:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540986#M42276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,to answer our original question. The extra intersection points are caused by the code which checks for intersection of endless lines. The lines extent to both sides into infinity. To get the right intersections you should check if the resulting points are in the "domains" of the input lines. I'm sure there is an easier way to do this, but see below how I did this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="yiv2923081832"&gt;&lt;P&gt;def linesIntersection(A, B, C, D):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = A[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1 = A[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x2 = B[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2 = B[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x3 = C[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y3 = C[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x4 = D[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y4 = D[1]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print x1, y1, x2, y2, "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ", x3, y3, x4, y4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print x3, y3, x4, y4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; denomenator = (((x1-x2)*(y3-y4)) - ((y1-y2)*(x3-x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print denomenator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if denomenator == 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P1 = (((x1*y2 - y1*x2)*(x3-x4)) - ((x1-x2)*(x3*y4-y3*x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Px = P1 / denomenator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P2 = (((x1*y2 - y1*x2)*(y3-y4)) - ((y1-y2)*(x3*y4-y3*x4)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Py = P2 / denomenator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Px: {0},&amp;nbsp; min(x)={1}, max(x)={2}".format(Px, min(x1, x2), max(x1, x2))&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Px: {0},&amp;nbsp; min(x)={1}, max(x)={2}".format(Px, min(x3, x4), max(x3, x4))&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Py: {0},&amp;nbsp; min(y)={1}, max(y)={2}".format(Py, min(y1, y2), max(y1, y2))&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Py: {0},&amp;nbsp; min(y)={1}, max(y)={2}".format(Py, min(y3, y4), max(y3, y4))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Px &amp;gt;= min(x1, x2) and Px &amp;lt;= max(x1, x2):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Px &amp;gt;= min(x3, x4) and Px &amp;lt;= max(x3, x4):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Py &amp;gt;= min(y1, y2) and Py &amp;lt;= max(y1, y2):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Py &amp;gt;= min(y3, y4) and Py &amp;lt;= max(y3, y4):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - The Intersection points are: ", Px, Py&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;polygon1 = [(1,0),(3,0),(3,2),(1,2),(1,0)]&lt;/P&gt;&lt;P&gt;polygon2 = [(0,1),(2,1),(2,3),(0,3),(0,1)]&lt;/P&gt;&lt;P&gt;poly1 = len(polygon1)&lt;/P&gt;&lt;P&gt;poly2 = len(polygon1)&lt;/P&gt;&lt;P&gt;# print poly1,poly2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i in range(0, poly1-1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A = polygon1&lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B = polygon1[i+1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in range(0, poly2-1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C = polygon2&lt;J&gt;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D = polygon2[j+1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linesIntersection(A, B, C, D)&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="yiv2923081832"&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="yiv2923081832"&gt;&lt;P class="yiv2923081832"&gt;&lt;/P&gt;&lt;P class="yiv2923081832"&gt;Kind regards, Xander&lt;/P&gt;&lt;P class="yiv2923081832"&gt;&lt;/P&gt;&lt;P class="yiv2923081832"&gt;&lt;EM&gt;edit: for some strange reason the code isn't formatting...&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 17:34:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540986#M42276</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-12-24T17:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Polygons Intersection Points</title>
      <link>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540987#M42277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it's works, It's true only for the case of both polygons have same no of points, other wise it's index is out of bound problem...&lt;/P&gt;&lt;P&gt;Well thanks for help...&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Dec 2014 06:32:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygons-intersection-points/m-p/540987#M42277</guid>
      <dc:creator>AhsanAbbas</dc:creator>
      <dc:date>2014-12-25T06:32:25Z</dc:date>
    </item>
  </channel>
</rss>

