import math def getBearing(part): # Returns the initial bearing in degrees from north following the great # circle path to the destination coordinates. firstpoint = part.next() lastpoint = part.next() lat1 = math.radians(float(firstpoint.Y)) lat2 = math.radians(float(lastpoint.Y)) dLon = math.radians(float(lastpoint.X)-float(firstpoint.X)) y = math.sin(dLon) * math.cos(lat2) x = math.cos(lat1) * math.sin(lat2) - \ math.sin(lat1) * math.cos(lat2) * math.cos(dLon) brng = math.atan2(y, x) return (math.degrees(brng) + 360) % 360; arcpy.AddField_management(YourFeatureClass,"angle","FLOAT") with arcpy.da.UpdateCursor(YourFeatureClass,["SHAPE@","angle"]) as cursor: for row in cursor: geom = row[0] part = geom.getPart(0) bearing = getBearing(part) print "Updating segment with bearing %f" % bearing row[1] = bearing cursor.updateRow(row)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.