# Intersection point of polygon and the line created by two points ArcPy

I have polygon layer. I selected the most distant vertex from centroid (picture: point A). (How to do that is in the answer here: Select the most distant vertex from polygon's centroid using ArcPy) What I need to do next is that I have to find intersection point (point B) of the outline of polygon and line created by centroid and the most distant point (line OA). • Stackoverflow has some decent answers: example. Check each segment with a da.SearchCursor. Feb 8, 2015 at 16:51

Field Calculator solution. See first post on how to use:

``````def getFarPoint(shp,n):
p=shp.centroid
g=arcpy.PointGeometry(p)
l=shp.boundary()
points=l.getPart(0)
m=len(points); lMax=0.0
for i in range(m):
pN=points.getObject(i)
d=g.distanceTo(pN)
if d>lMax:
lMax=d;pBest=pN
xC,yC=p.X,p.Y
xF=pBest.X;yF=pBest.Y
pBest.X=xC+(xC-xF)
pBest.Y=yC+(yC-yF)
L=arcpy.Polyline(arcpy.Array([pBest,p]))
arcpy.Intersect_analysis([l,L],"in_memory/pnts", "","", "point")
g = arcpy.Geometry()
geometryList = arcpy.CopyFeatures_management("in_memory/pnts",g)
pBest=geometryList.getPart(0)
pick=[pBest.X,pBest.Y]
return pick[n]
``````

What you seek is code for segment-segment intersection. I.e., you have a segment (or ray) from O, and you need to intersect it with every edge of your polygon, and then select the closest. (It is generally best to be mindless about this, and just iterative over all polygon edges, rather than try to eliminate edges that have no chance of intersecting.) You can find segment-segment intersection code all over the web, including my own SegSegInt code described in Computational Geometry in C.