How to Add Stationing to Line Features

 

Ever wonder how to add stationing to line features in ArcGIS? In this blog entry I will give an example of how to accomplish just that!

For a line feature to display stationing or hatchings, the feature has to be converted to a route. Add the “Route Editing Toolbar” to your display. Start an edit session then click the “Make Route” icon. From here select the line feature you wish to make a route. In the “Make Route” window select where you would like the beginning of the stationing to start and then select Measure Field > Shape_Length for the measured values. Leave the rest as the default. Next, click “Make Route”.

example1a

Next, go into the layers properties and click on the “Hatches” tab. Here add a “Hatch Definition” and select it in the left hand side of the window.

example1

In this window, select “Label Settings” which brings up the following window:

example3

Next, click “Build a text expression> Expression” button. This presents the “Hatch Text Expression” window.

example4

Below is what is shown in the above expression window in full detail:

 

def FindLabel ( esri__measure ):

EM = str(int(round(esri__measure)))

if len(EM) == 0:

return “0+00”

elif len(EM) == 1:

return “0+0{0}”.format(*EM)

elif len(EM) == 2:

return “0+{0}{1}”.format(*EM)

elif len(EM) == 3:

return “{0}+{1}{2}”.format(*EM)

elif len(EM) == 4:

return “{0}{1}+{2}{3}”.format(*EM)

elif len(EM) == 5:

return “{0}{1}{2}+{3}{4}”.format(*EM)

elif len(EM) == 6:

return “{0}{1}{2}{3}+{4}{5}”.format(*EM)

This creates the stationing 00+00. Below is an example of having intervals every 1000 feet with smaller intervals at 100 feet.

example5

The end result stationing!

example6

8 thoughts on “How to Add Stationing to Line Features

  1. This is so awesome, thank you for posting this workaround. I cannot get the hatching to show appropriatly. I’ve copied your text expression into notepad++ and pasted it back into The Hatch Text Expression, under the advanced setting. I cannot get the expression to work. I get an “Error 3 Line 12 – Syntax error”. The string looks good to my untrained eye.

    • Hey Mike,

      I apologize for the late reply. You can email me or call me office to trouble shoot the issue.

      Thanks,

      Dan

  2. I could not get the script to work either. I get an error. Did you resolve it with the other person?

    • Hey Kathy,

      Thank you for replying. Below is the revised expression.

      def FindLabel (esri__measure):
      EM = str(int(round(esri__measure)))
      if len(EM) == 0:
      return “0+00”
      elif len(EM) == 1:
      return “0+0{0}”.format(*EM)
      elif len(EM) == 2:
      return “0+{0}{1}”.format(*EM)
      elif len(EM) == 3:
      return “{0}+{1}{2}”.format(*EM)
      elif len(EM) == 4:
      return “{0}{1}+{2}{3}”.format(*EM)
      elif len(EM) == 5:
      return “{0}{1}{2}+{3}{4}”.format(*EM)
      elif len(EM) == 6:
      return “{0}{1}{2}{3}+{4}{5}”.format(*EM)

      • Hi Daniel,
        That still didn’t work and says there is an error. I have check the advanced, and the error when I verify is:
        Error 0 on line 0. Error running expression: FindLabel(ESRIExpresionArg0)
        Traceback (most recent call last):
        File “”, line 1, in
        NameError:name ‘FindLabel’ is not defined

Comments are closed.