creating polylines from a point with specific azimouth

4147
3
Jump to solution
02-09-2015 12:50 PM
KONPETROV
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?

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
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')

Capture.PNG

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

View solution in original post

3 Replies
DanPatterson_Retired
MVP Emeritus

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

DarrenWiens2
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')

Capture.PNG

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

KONPETROV
Occasional Contributor III

THAT WAS HELP F U L L !

0 Kudos