1

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). enter image description here

  • Stackoverflow has some decent answers: example. Check each segment with a da.SearchCursor. – gm70560 Feb 8 '15 at 16:51
1

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[0].getPart(0)
    pick=[pBest.X,pBest.Y]
    return pick[n]
| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.