def main(): import arcpy, os # input points pnts = [[200,800],[100, 500],[300,100],[1000,200],[1200,700]] # input angle angle_geo = 100 # geographic degrees angle_ari = arithmatic_geographic(angle_geo) # = 350 in arithmetic degrees # create a multi point from input points arr_mp = arcpy.Array() for p in pnts: pnt = arcpy.Point(p[0], p[1]) arr_mp.add(pnt) mp = arcpy.Multipoint(arr_mp) # determine convex hull of input points pol = mp.convexHull() # get boundary of convex hull polygon bnd = pol.boundary() # let's take centroid for Q q = pol.centroid # determine line length (enough to intersect boundary) length = pol.extent.width + pol.extent.height # create second point (Q2) dx, dy = LengthDir(length, angle_ari) q2 = arcpy.Point(q.X + dx, q.Y + dy) # make line of Q and Q2 arr_line = arcpy.Array() arr_line.add(q) arr_line.add(q2) line = arcpy.Polyline(arr_line) # intersect (other, dimension), dimension can be 1 or 2 pnt_int = line.intersect(bnd, 1) # returns mp # print resulting intersection coordinates for p in pnt_int: print p.X, p.Y def arithmatic_geographic(angle): new_angle = angle + 270 while new_angle > 360: new_angle -= 360 return 360 - new_angle def LengthDir(length, angle): import math radian_angle = angle * math.pi / 180 return length * math.cos(radian_angle), length * math.sin(radian_angle) if __name__ == '__main__': main()
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.