Select to view content in your preferred language

# creating polylines from a point with specific azimouth

4296
3
Jump to solution
02-09-2015 12:50 PM
Occasional Contributor III

Hello i have a point and i want to create polylines for every 5o from 180o to 360o (north azimuth). How can i do that with azimuth and bearings?

Tags (4)
1 Solution

Accepted Solutions
MVP Honored Contributor

Here's how you can automate this with arcpy geometry objects:

```>>> import math
>>> length = 100000
>>> lines = []
>>> degrees = 5
>>> with arcpy.da.SearchCursor("YOUR_POINT_LAYER_NAME_HERE","SHAPE@") as cursor:
...    for row in cursor:
...        for i in range(360/degrees):
...            dx = math.cos(math.radians(i*degrees))*length
...            dy = math.sin(math.radians(i*degrees))*length
...            startPoint = row[0].centroid
...            endPoint = arcpy.Point(row[0].centroid.X+dx,row[0].centroid.Y+dy)
...            line = arcpy.Polyline(arcpy.Array([startPoint,endPoint]))
...            lines.append(line)
...
>>> arcpy.CopyFeatures_management(lines,'in_memory\lines')```

edit: I just read the point about limiting between 180 and 360. This can be incorporated into the above script.

3 Replies
MVP Emeritus

if you want geodesic line features, check the help top here on distance and bearing

MVP Honored Contributor

Here's how you can automate this with arcpy geometry objects:

```>>> import math
>>> length = 100000
>>> lines = []
>>> degrees = 5
>>> with arcpy.da.SearchCursor("YOUR_POINT_LAYER_NAME_HERE","SHAPE@") as cursor:
...    for row in cursor:
...        for i in range(360/degrees):
...            dx = math.cos(math.radians(i*degrees))*length
...            dy = math.sin(math.radians(i*degrees))*length
...            startPoint = row[0].centroid
...            endPoint = arcpy.Point(row[0].centroid.X+dx,row[0].centroid.Y+dy)
...            line = arcpy.Polyline(arcpy.Array([startPoint,endPoint]))
...            lines.append(line)
...
>>> arcpy.CopyFeatures_management(lines,'in_memory\lines')```

edit: I just read the point about limiting between 180 and 360. This can be incorporated into the above script.

Occasional Contributor III

THAT WAS HELP F U L L !