2

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

1

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!

  • Is there a way to populate the attribute table for the rotation field to be perpendicular to the road? The advice you gave me turns all the labels pending on the angle of the point. Or will I have to first turn the points so they are perpendicular to the road? – Anonymous24 Nov 24 '15 at 19:16
  • I forget what tool it is, but you have to get the bearing of the line. Google search reveals a couple of Python scripts that do this. Then use that value +90 degrees to become perpendicular. – Maksim Nov 24 '15 at 19:20
0
  1. Add field ANGLE, type float to your points.
  2. Add field STREET_REC, type long integer to your street centrelines.
  3. Populate it using field calculator with sequential number, e.g. [FID]
  4. Rename road layer to STREETS
  5. Add spatial join to point as shown below

enter image description here

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")[0]
 q=r'"STREET_REC"='+str(n)
 with arcpy.da.SearchCursor(lr, "Shape@",q) as cursor:
  for row in cursor:
   street=row[0];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

enter image description here

Use field ANGLE in labelling dialog.

RESULT:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.