Hi,
I'm trying to get the bearing of a geodesic line in a script, but cannot find a tool that can be used for that in arcpy. The Distance and Direction tool lets me get the bearing, however cannot be used in arcpy.
Any help would be appreciated!
Try calculate geometry?
Add Geometry Attributes (Data Management)—ArcGIS Pro | Documentation
Only issue is that it modifies your table.
Untested, but this should get you in the ballpark:
# Get this polyline object somehow, cursors with the "SHAPE@" token work well line = get_line() sr = line.spatialReference start = arcpy.PointGeometry(line.firstPoint, spatial_reference=sr) end = arcpy.PointGeometry(line.lastPoint, spatial_reference=sr) angle, distance = start.angleAndDistanceTo(end, "GEODESIC")
Peep the "angleAndDistanceTo" part of the PointGeometry docs for more info.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.