Azimuths

4319
9
07-30-2014 02:11 AM
CamillaRootes
New Contributor III

Hi everyone

I have a series of polygons (representing glacier margins) and I would like to know the azimuth of each segment of a polygon's edge. It seems that there were ways of doing this in the field calculator, but I've not been able to find out how to do it in Arc 10.1. Does anyone know how to get these azimuths?

 

Note that my license does not cover the Polygon to Line tool. So I'm wondering if I might need to re-draw the polygons as a series of seperate polylines - is this necessary and how would I then get the azimuth of each polyline?

 

Thanks in advance for your help!

0 Kudos
9 Replies
JohannesBierer
Occasional Contributor III

You could use Et Geowizard to convert Polygon to Polyline and perhaps use this old script:

Find Polyline Angle

0 Kudos
CamillaRootes
New Contributor III

Hi Johannes

I've got the ET Geowizard working and have run the polygons to polylines conversion (thanks for pointing me in the direction of this software - it looks like being very useful!). But I can't get that old Find Angle script to work in Arc 10.1.

Maybe I'm missing something in how to get Arc to run this script but I can't find a away of doing it. The script is in VB, so I can't run it in the Python window. Is there another way of running this script? I've tried converting the language to Python via an online code convertor then running it in the Python window. This produces a script that runs without throwing errors but it doesn't seem to do anything. I'm fairly new to the programming game, so may well just be missing something very obvious. Any thoughts?

Thanks again for your help so far

0 Kudos
JohannesBierer
Occasional Contributor III
0 Kudos
CamillaRootes
New Contributor III

Hmm, that script looks like it should work but it's throwing an error when I try and run it. The error is:

File "<string>", line 4, in GetAzimuthPolyline

AttributeError: 'str' object has no attribute 'lastpoint'

I'm testing the code on a shapefile containing only one line (to simplify things) but am still getting this error. Wondering if I need to add attribute fields describing the line's end points before I can run this code? Surely Arc already has this information so there must be a way of referring to it in Python that works?

Definately missing the field calculator right now, this would have all been done a dusted if I could use that!

0 Kudos
JohannesBierer
Occasional Contributor III

For me the field calculator works?

Maybe this could help you with a script?

Calculate angle of each line in a polyline shapefile

CamillaRootes
New Contributor III

I've previously tried running the suggested script in that thread and it throws the error:

File "<string>", line 2, in GetAzimuthPolyline

AttributeError: 'str' object has no attribute 'x'

Failed to execute (CalculateField).

I can't work out why as everything appears right and the code should definately work.

0 Kudos
JohannesBierer
Occasional Contributor III

OK - with the script I get the same error.

Don't know what the problem could be ....

0 Kudos
JohannesBierer
Occasional Contributor III

You could post the script in the python forum, so that the cracks there could have a look on it?

CamillaRootes
New Contributor III

I've put up a question about the code in the Python place, here's the link if you're interested in keeping up with it Calculating polyline azimuth - code error

Thanks for your help!

0 Kudos