I have a point shapefile with attributes and I want to make the label be perpendicular to a line shapefile, is this possible? Basically my points represent houses and I want the house label to show up perpendicular to the line segment (road). My line segments do not all run the same way so I have to manually turn my labels and I was wondering if there was a way to automatically create the label to be perpendicular. My points do not lie on the lines either, there is space between them. I am using arcmap 10.3
Using the Maplex labeling engine, click on Label Manager and select your point layer. Go to properties, and Label Position. Within Label Position, choose rotate by attribute, and click options. There you can set label rotation by a field, or by Alignment Type, perpendicular being one of those. Hope this helps!
- Add field ANGLE, type float to your points.
- Add field STREET_REC, type long integer to your street centrelines.
- Populate it using field calculator with sequential number, e.g. [FID]
- Rename road layer to STREETS
- Add spatial join to point as shown below
Run this field calculator expression on field ANGLE of SJ table
import math pi=math.pi def getAngle(shp,n): mxd = arcpy.mapping.MapDocument("CURRENT") lr=arcpy.mapping.ListLayers(mxd, "STREETS") q=r'"STREET_REC"='+str(n) with arcpy.da.SearchCursor(lr, "Shape@",q) as cursor: for row in cursor: street=row;break pointPosition= street.measureOnLine(shp) f=max(0,pointPosition-0.01) t=min(street.length, pointPosition+0.01) p1=street.positionAlongLine(f).firstPoint p2=street.positionAlongLine(t).firstPoint dX=p2.X-p1.X dY=p2.Y-p1.Y if dX==0:dX=0.0001 if dY<0: return math.atan(dY/dX)/pi*180-90 return math.atan(dY/dX)/pi*180+90
Use field ANGLE in labelling dialog.