Select to view content in your preferred language

Can I label a points layer perpendicular to a line layer?

3767
15
Jump to solution
04-30-2018 05:08 AM
PaulWirth
Regular Contributor

I have a points layer (Electrical Transmission structures) and a Transmission line layer. The points layer sits on top of the line layer and because the line layer changes direction all the time it is hard to label the points layer sometimes. What I would like to do is label the points layer perpendicular to the line layer.

Does anyone have an answer for me?

0 Kudos
15 Replies
XanderBakker
Esri Esteemed Contributor

Hi @GIS_Rookie ,

I suppose you can do something like this at the end of the script:

# start insert cursor
flds_out = (fld_label, fld_angle)
with arcpy.da.UpdateCursor(fc, flds_out) as curs:
    for row in curs:
        lbl = row[0]
        if lbl in dct_res:
            angle = dct_res[lbl]
            if angle < 0: 
                angle += 360
        else:
            pass
            # angle = 400
        curs.updateRow((lbl, angle, ))
GIS_Rookie
Occasional Contributor

Thanks @XanderBakker ! This worked for me 🙂 

Just curious about why those numbers are heading to north and south, not in one direction? And some of numbers lost their directions. Maybe there is some kind of explanation? Tried to build 1 script from 2 but without success. 

2.JPG

P.S. Saw your other posts (Translating the lowest overhead power lines into a continuous surface). They are also interesting!

Never stop learning
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @GIS_Rookie ,

So, ArcGIS has its labeling engine Maplex that has a lot of settings you can play with to get the result you want. I understand that it would be better to have them all point in a certain direction in this case. However, if you have a line that describes a circular movement, it would be best that in a certain location the text switches its orientation in order to be closer to horizontal and enable readability for the end-user. 

I also had some issues with the texts near the start or end of the line, not sure what is going on there. 

MarcoConopio1
New Contributor

Hi @XanderBakker !

 

I am trying to run your script and I have some questions.

  1. What is the fc_out shapfile? Is this the line shapefile to which the labels will be perpendicular to?
  2. I tried running both of the script, with the assumption that the fc_out is the alignment to which the labels will be perpendicular to, and I keep getting this error MarcoConopio1_0-1650248628757.png

Thank you and would greatly appreciate any help!

 

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @MarcoConopio1 ,

The error is pointing to the use of a field that does not exist in the featureclass. Can you check that the fields with names assigned to the variables "fld_orden" and "fld_label" exist in your featureclass?

0 Kudos
OzzOutao_UoM
New Contributor

Hi, @XanderBakker . Thanks a lot for your script, it’s very useful.


I am having an issue with angles as when my ‘ANGLE2’ field gets populated the only value I get is: -116.907208734888 (for every row).
I am basically trying to draw a short line that will mark 1 km along the road. I have created points along the road, and now trying to label them with ‘___’.
I want this labels to be perpendicular to the road.
I have added two fields to my points shapefile (‘Pole’ with values as ‘___’ (data type: text), and “ANGLE2” with empty values (data type: double)).

Please take a look at the attached file for a visual explanation.

I will appreciate any advise, thanks!

0 Kudos