I'm using a Python code block to calculate the azimuths of 11 polylines within a single shapefile. When I run the code block the field calculator it works fine for 8 of the polylines but returns an incorrect result of '0' for 3 polylines. The geoprocessing results give the following reason:
WARNING 000405: No records within table
The polyline shapefile was aquired as a single shapefile data download, so I don't understand why 3 of the polyline features seem to have no records. They don't appear any different in the attribute table, which looks like this:
I doubt it's an error with my code block because I've used this code for many other datasets and not had a problem. Besides it is computing the correct results for the other polylines in this shapefile. But just in case, here is the code:
radian = math.atan((shape.lastPoint.X - shape.firstPoint.X)/(shape.lastPoint.Y - shape.firstPoint.Y))
degrees = math.degrees(radian)
if degrees < 0:
return degrees + 360
The expression applied is:
Azimuth = GetAzimuthPolyline(!shape!)
Can anyone suggest a reason why I'm having this problem?
I'm using Arc 10.1 with the basic licence.