# Compute angles between intersecting roads

Question asked by Ezbot on Aug 14, 2017
Latest reply on Oct 11, 2018 by Mattheus_Prudencio

I'm trying to compute the angles between intersecting roads using Darren Wiens script found at: https://community.esri.com/message/582193?q=calculate%20angle%20of but am receiving the following error:

Runtime error  Traceback (most recent call last):   File "<string>", line 53, in <module>   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 3246, in AddField     raise e ExecuteError: ERROR 000732: Input Table: Dataset in_memory\points does not exist or is not supported

My code is:

>>> import arcpy
... import os
... sr = arcpy.Describe(fc).spatialReference
... out_fc = r'in_memory\points'
... int_pt = r'in_memory\int_pt'
... arcpy.Dissolve_management(fc,diss_fc,["name"],"","SINGLE_PART")
... arcpy.Intersect_analysis(diss_fc,int_pt,output_type='POINT')
... diss_int_pt = r'in_memory\diss_int_pt'
... arcpy.Dissolve_management(int_pt,diss_int_pt,'#',[["OBJECTID","MIN"]],"SINGLE_PART")
... buff = r'in_memory\buff'
... buff_line_int = r'in_memory\buff_line_int'
... arcpy.Intersect_analysis([buff,fc],buff_line_int,output_type='POINT')
... sing_buff_line_int = r'in_memory\sing_buff_line_int'
... arcpy.MultipartToSinglepart_management(buff_line_int,sing_buff_line_int)
... new_points = {}
... with arcpy.da.SearchCursor(diss_int_pt,['OID@','SHAPE@'],spatial_reference=sr) as cursor1:
... for row1 in cursor1:
... cent_pt = row1[1].centroid
... angs = []
... with arcpy.da.SearchCursor(sing_buff_line_int,'SHAPE@','\"FID_buff\" = ' + str(row1[0]),spatial_reference=sr) as cursor2:
... for row2 in cursor2:
... buff_pt = row2[0].centroid
... dx = cent_pt.X - buff_pt.X
... dy = cent_pt.Y - buff_pt.Y
... if dx < 0 and dy <= 0:
... ang = math.degrees(math.atan(abs(dy/dx)))
... if dx <= 0 and dy > 0:
... ang = math.degrees(math.atan(abs(dx/dy))) + 270
... if dx > 0 and dy >= 0:
... ang = math.degrees(math.atan(abs(dy/dx))) + 180
... if dx >= 0 and dy < 0:
... ang = math.degrees(math.atan(abs(dx/dy))) + 90
... angs.append(ang)
... angs.sort()
... for i in range(1,len(angs)):
... mid_ang = ((angs[i] + angs[i-1])/2)
... ang_diff = angs[i] - angs[i-1]
... new_point = arcpy.PointGeometry(arcpy.Point(new_x, new_y),sr)
... new_points[str(row1[0]) + '_' + str(i)] = [ang_diff,new_point]
... mid_ang = (((360-angs[-1]) + angs[0])/2) - (360-angs[-1])
... ang_diff = (360-angs[-1]) + angs[0]
... new_point = arcpy.PointGeometry(arcpy.Point(new_x, new_y),sr)
... new_points[str(row1[0]) + '_0'] = [ang_diff,new_point]
... arcpy.CreateFeatureclass_management(os.path.dirname(out_fc),os.path.basename(out_fc),'POINT',spatial_reference=sr)