ArcPy – Calculating Orientation of Polygon Sides

arcgis-10.0arcpy

I want to examine the orientation of each line in a polygon so that I can calculate their solar exposure. Each polygon represents a building, and has an associated height. For the moment, I just want to consider the orientation, and will later consider shading issues.

One approach I thought was to split the polygon into lines, and to calculate the orientation of each line, but the difficulty is that I then have to identify the outer face of that line. Although most of the polygons are simple four-side figures with straight lines, there are a small number where this is not the case (an issue which I just want to consider, but do not have to solve yet).

I'm familiar with python and planned on doing this all from a script.

Best Answer

If you just want majority orientation, check out @Mapperz 's answer above.

Otherwise, as you say you could split the polygons into lines using the Polygon To Line tool. This adds a left and right FID field, where the field is -1 if there is no outer polygon - this can cause a bit of mucking about though if your buildings are adjacent or overlap.

From there you could split your lines at every vertex (maybe use Split into COGO lines), and then calculate the angles on each of the lines (potentially by Updating COGO attributes).

Assuming you have your angle field calculated from North the the aspect will be correct where the left_FID is -1, and to get the aspect when the right_FID is -1 just add 180°. Then based on the original FID you can aggregate, get the majority aspect based on length etc.

The Polygon to line tool is scriptable, (as far as I know) COGO tools are not, so you would have to come up with something there yourself.

Hope this helps!