How to Prepare Railroad Data For Use with ArcGIS Roads andHighways, Including Building Linear Referencing
BackgroundThe steps below start with a line dataset of rail centerlines and a point dataset of track switches
which are where three or more track lines will need to snap to. The point dataset of trackswitches also needs to contain points that represent bumper stops in situations where the endof a track centerline just stops (spurs, turnouts, terminals, dead ends). The rail centerlines become
the edges in this network, and the track switches and bumper stops serve as the junctions in
the network. For more info, contact: Jim Barry, @Esri, jbarry@esri.com, twitter: @JimBarry
Prepping the data
While ArcGIS Roads and Highways only works when all of the data is stored in enterprisegeodatabases, and served as web services from ArcGIS Enterprise, there is a lot of prep work
you can do on that data using locally stored file geodatabases. The steps below do as muchprep work as possible in file geodatabases, then later in the steps, the FGDBs are imported into
EGDBs, for the remaining steps.
Steps
1-- Start with a FGDB containing a FDS. (quick definitions - FGDB: File Geodatabase, FDS: Feature Dataset, FC: Feature
Class)*2-- In that FDS there should be a PolylineMZ feature class of tracks to serve as network edges.
*3-- In that FDS there should be a PointMZ feature class of switches and track terminal bumpers to serveas network junctions.
*(Note about Steps 2 and 3: To check to see if a feature class supports M and Z, in Catalog, right click on the featureclass, click Properties, then in the Properties popup, on the Source tab, check for “Yes” in the rows labeled“Coordinates have Z value” and “Coordinates have M value”. If your feature classes do not support M and Z, you
can use the Export Features tool and its Environments tab to ensure that the exported output supports M and Z.)

4-- Every track polyline should start and end at either a switch point, or at a track end bumper point.
Check to ensure this is true. If not, then edit them into the switch points FC.
5-- And of course since both FCs are in the same FDS, they must share the same spatial reference. If you
get any errors that mention mismatched spatial reference as you put these two FCs into the same FDS,
you’ll need to use the Project tool on one or both of them to get them into the same spatial reference as
the FDS.
6—Next. It’s important to ensure that all of the FCs in the FDS have valid network topology. Building a
Trace Network, then Enabling, then Validating topology is a great way to do this, and where topology

errors are found, fix them all until you can Validate a clean network topology for all FCs that will be
participating in the LRS. For railroads, at a minimum this will be the track FC and the switch FC.
7-- Another tip, is to use an “arrow along” line symbol on the tracks layer in order to visually inspect thedigitized direction of the track lines. You’ll have smoother results if you can make it so that all track lines
flow in the same digitized direction. When it comes to mileposts/kilometerposts, check with the railroad
to understand which direction that post measurements are ascending, then fix the data so that digitized
directional flow conforms. This is not required of course. It’s just best practice for building a tightfoundational database. And don’t just check the main tracks, but also the crossovers, spurs, loops, andyards. This is not always perfectly possible given some types of track organization like U-curves,
lollipops, turntables, and other structures that might pose a challenge, but do your best. The polylinesthat are misoriented, you can select, then use the Flip Line tool to flip their digitized direction to get the
track data to flow in the same direction.
8-- What we're going to do below is prepare the data for use with ArcGIS Roads & Highways. To do thiswill follow several steps, using tools you'll find in the toolboxes: Linear Referencing and Location
Referencing. Here is a list of tools, in order, that you will be using, in case you want to move them into
your Favorites list:
Create Routes
Add Field
Calculate Field
Create LRSCreate LRS Network
Append Routes
Generate Calibration Points
Generate Routes
Create LRS Event
9-- Create a new column in the polyline feature class to store the route names. For the purposes of therest of these instructions, we’re going to assume that you give this field the name “RouteName”.
Populate that field with route name values, in a way that all polylines that you want to be in the sameroute, should get the same route name value. For example, each of the main lines along the way should
be its own route from start to finish, but then each crossover, spur, and loop should be their own
routes. It helps to use a consistent naming structure.
10-- In the Linear Referencing toolbox, run the Create Routes tool.
•••

Input line features: use the polyline FC from Step 2
Route Identifier Field: should be “RouteName” (or the name from Step 9)
Output Route Feature Class: if the polyline FC is called "abc" then call the output "abc_routes".
(IMPORTANT!!: The tool will—by default--try to write this output routes FC into the default project FGDB. Instead,navigate to the same FDS the tracks and switches FCs are stored in, to ensure that the new routes FC output will go
into that same FDS.)••

Measure Source: "Length of Features" (don't worry, we can recalibrate later)
Coordinate Priority: [Whatever makes sense for your data. What helps is if you use arrowsymbology to inspect the digitized direction of your lines in order to choose the best orientation
setting in this pull-down.]•••Measure Factor, 1; Measure Offset, 0;
Ignore spatial gaps, check on; Build index, check on;
Click Run

11—Add some new columns to this new output routes FC and calculate values into them. One way to
do this is to open the attribute table, then using its Add and Save buttons, then for each new field, rightclicking the field header to get to the field calculator. Another way to do this is with the Add Field andCalculate Field tools. Either way:
•
•
•
•
•

•
•
•
•

add two new Date columns called: FromDate, ToDate.
add a new Text(38) column called: RouteId
on the Fields ribbon, click Save, to save these new columns.
close the Fields panel, returning to the attribute table panel.
field calc FromDate using Python: FromDate = datetime.datetime.now(), or Arcade:
FromDate = Now(), then click Apply or OK. (Note that using Python, the time will be pulled off
your machine, which is probably local time, but if you use Arcade, the time will be GMT/Zulu/UTM+0
time.)

leave ToDate null
Now calculate the RouteID field with a Guid using Arcade: RouteId = Guid().
or…
If you’d rather use Uuid’s instead of Guid’s, you can use Python instead of Arcade. If so, thenwrite this line into the “RouteId =” textbox:'{' + str(uuid.uuid4()) + '}'And write this line into the “Code Block” box, then click Apply or OK:
import uuid

12-- Create a new empty LRS: Location Referencing tools > Configuration > LRS > Create LRS
•
•
•
•
•
•
•
•
•

Input Location: use the FDS from Step 2
LRS Name: if your FDS is "abc_fds", call this new lrs "abc_lrs"
Centerline Feature Class Name: default Centerline
Calibration Point Feature Class Name: default Calibration_Point
Redline Feature Class Name: default Redline
Centerline Sequence Table Name: default Centerline_Sequence
Spatial Reference: [same as the ~routes FC in the FDS]
Tolerances and Resolutions: just take the defaults
Click Run

13-- Back in the map, create a Group Layer called "base layers" and put your original polyline, point, androute FCs into it, to sort of get them out of the way.
14-- Create a new LRS Network: Location Referencing tools > Configuration > LRS Network > Create LRS
Network••

Input Location: use the FDS that contains the routes FC you created in Step 10.
LRS Name: Should auto-populate with the name of the LRS you had just created, which is stored
in that FDS. If it doesn't appear, then you may not have been storing everything into the same

•
•
•
•
•
•
•

FDS, as you need to be. Important to remember that these tools often try by default to send
output to the project's default FGDB. You should always navigate the output away from that,and instead send the output to the FGDB you created above where everything else is being
storedLRS Network Name: if your FDS is "abc_fds" and your LRS is "abc_lrs", make it"abc_lrs_network"
Route ID Field: RouteId
Route Name Field: RouteName
From Date Field: FromDate
To Date Field: ToDate
Derive from line network, unchecked; Include fields to support lines, unchecked; Measure Unit,
Miles (US Survey);
Click Run

15-- Append the routes into the LRS Network: Location Referencing tools > Append Routes
•
•
•
•
•
•
•
•
•

Source Routes: use the routes FC you created in Step 10
LRS Network: use the LRS Network you created in Step 14
Route ID Field: default, should be “RouteId”
Route Name Field: default, should be “RouteName” (or the name from Step 9)
From Date Field: default, should be “FromDate”
To Date Field: default, should be “ToDate”
Field Map section: just leave them all blank by default
Load Type: default, should be “Add”
Click Run

16-- Generate the calibration points: Location Referencing Tools > Generate Calibration Points
•
•
•
•
•
•
•
•

Input Polyline Features: use the routes FC you created in Step 10
Route ID Field: use the RouteId field from Step 11
FromDate, ToDate: use the FromDate and ToDate fields from Step 11
Calibration Point Feature Class: use the Calibration_Point layer created in Step 14
LRS Network: use the LRS network you created in Step 14
Calibration Direction: use Digitized direction
Calibration Method: use Geometry length.

•

Note: After the tool runs, it may return a warning, despite completing successfully, with a note about M-resolutions
being different between the routes FC and the LRS network. I’ve found most of the time that the difference is at adecimal precision far smaller and insignificant than the accuracy of any dataset you’ll be using. Ultimately, that’s up toyou, but for most purposes, we can just keep going.

17—Generate routes: Location Referencing Tools > Generate Routes••

Input Route Features: use the LRS Network you created in Step 14
Record calibration changes…: leave unchecked

18—Create a LINE event layer to store linear events that record and display max speed limits along therail line: Location Referencing Tools > Configuration > Create LRS Event
•
•
•
•
•
•
•
•
•
•
•
•

Parent LRS Network: use the LRS network you created in Step 14
Event Name: name it “MaxSpeed”
Geometry Type: Line
Event ID Field: Eventid
Route ID Field: FromRouteId
From Date Field: FromDate
To Date Field: ToDate
Location Error Field: LocError
MeasureField: FromMeasure
To Measure Field: ToMeasureStore Route Name: check on (the default is ‘off’, but it doesn’t hurt to turn it on)
Route Name Field: RouteName

19-- Create a POINT event layer to store point events that record and display crossings (grade, overpass,underpass) along the rail line: Location Referencing Tools > Configuration > Create LRS Event
•
•
•
•
•
•
•
•
•
•

Parent LRS Network: use the LRS network you created in Step 14
Event Name: name it “Crossings”
Geometry Type: Point
Event ID Field: Eventid
Route ID Field: FromRouteId
From Date Field: FromDate
To Date Field: ToDate
Location Error Field: LocError
MeasureField: MeasureStore Route Name: checked off (default)

20-- Ensure the FDS components hava global IDs and have editor tracking enabled
•
•
•
•
•

In Catalog, navigate to the FDS you’ve been working with since Step 1
Right-click the FDS, then click “Manage”
In the Properties popup dialog, in the Manage tab, ensure the Global IDs and Editor tracking areboth checked on
When you check on Editor tracking, it will drop down a few field names and pull downs, justaccept all the defaults.
Click OK. And watch the process run until two green check boxes appear. When successful, thedialog will vanish.

21—Ensure the Centerline_Sequence table has global IDs and editing tracking enabled••

In Catalog, navigate to the FGDB you’ve been working with since Step 1
Right click the Centerline_Sequence table, then click “Manage”•••In the Properties popup dialog, in the Manage tab, ensure that Global IDs and Editor tracking arechecked on. You can check Attachments on or off, your choice.
When you check on Editing tracking, it will drop down a few field names and pull downs, justaccept all the defaults.
Click OK. And watch the process run until two green check boxes appear. When successful, thedialog will vanish.

Maybe put all the GlobalIDs into all the tables and FCs first%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Move the data to ArcGIS Enterprise
Now you have gotten as far as you can go with FGDBs. The next set of steps involve moving allof your prepared data into Enterprise Geodatabases so that you can begin working with yourdata using ArcGIS Roads & Highways Server, which is an extension of ArcGIS Enterprise.
22. Create a new empty Enterprise GDB for each of the FGDBs that you want to port over.
23. run Create Enterprise GDB tool
• database platform - SQL Server (for example, but whatever yours is)• instance – mydb (for example, or whatever your database instance is)• database - [what i want the db to be called]• database administrator – gdb (for example, or whatever your dba name is)• database administrator password - [your database administrator password]• geodatabase administrator password - sde• sde owned schema - uncheck it• tablespace name – [left blank]• authorization file - [Server_Ent_Adv.ecp file]• spatial type – ST_Geometry
23b. Create a connection to this new EGDB that you created•

Go to Catalog, in the Project tab, click to expand the “Databases” section to see if the new
Geodatabase you created in Step 23 appears. If it does, move on to 24, but if not, then do these
additional steps here:o Right click on Databases, and click “New Database Connection” from the popup menuo Fill out these entries on the popup dialog:▪ Database Platform: PostgreSQL▪ Instance: your db instance▪ Authentication Type: Database authentication▪ Username: your username▪ Password: your pwd▪ Save User/Password: check on▪ Database: your db name

24. once the EGDB is created, then work on permissions

•
•
•
•

Go to Catalog, in the Project tab, in the Databases section, right click on the connection that
contains your new EGDBIn the popup menu, click on Connection Properties
In the Database Connection dialog, in the Database dropdown, select your new EGDB
Click OK

25. Copy the database connection into the Folders section of the Catalog
•
•
•
•
•

Go to Catalog, in the Project tab, in the Databases section, right click your new databaseIn the popup menu, click Copy
In the Folders part of the Catalog, right click your project folder (the one that has the icon of theyellow folder with a white house on it) and then click Paste
At that point it still has the name of the database, but rename that connection using the old sde
naming convention. For example, if the database is called “my.sde”, then if your dataset is for LA
Metro, perhaps call it “lametro@gdb@my.sde”
Then right click that database, then click on “Connection Properties” in the popup menu to open
the “Database Connection” dialog box, to check to ensure that the database connection ispointing to the right database.

26. Ok, now that you've got all the right database connections you want, under the Folders part ofCatalog, then you can start copying over everything from your FGDB into the EGDB.
27. go to the FGDB, open it up, and copy its contents to the EGDB connection•••

Inside your FGDB, but not inside the FDS, find the set of 3 flat tables (Centerline_Sequence,
Lrs_Edit_Log, Lrs_Locks)
Copy those three tables into the root of your new EGDB
Next, if you have a table called “Centerline_Sequence_ATTACH” and a relationship called“Centerline_Sequence_ATTACHREL”, copy those over too.
Next, if you have any feature classes that are not in the FDS, copy those over as well
Finally, copy the entire FDS at once, and paste it into your new EGDB.

•(Note: It’s important to copy these components over separately and in the order listed above.)•••Open the EGDB connection and refresh it to see that everything made it over.

28. run Change Privileges tool•

Input Dataset: navigate to the EGDB, then select one of the FCs•(If that doesn’t work, then you may need to fully qualify it as '[your_server]/arcgis'. To verify that, go into Control
Panel > Administrative Tools > Computer Management > Local Users and Groups > Users > find the "ArcGIS user
account")••••

View: select Grant view privileges
Edit: Grant edit privileges
Click Run
If that works, then go back to the Input Dataset pulldown and run the tool on the other rootlevel FCs, and then finally the FDS itself.

29. check to see if the privileges of the layers took correctly

•
•
•
•

Go to Catalog, and find the FDS that’s in your new EGDB.
Right click on one of the FCs inside the FDS.
From the popup menu, click Privileges…
In the Privileges popup, “[your_server]\arcgis” should be listed with all checks on

30. Ensure that the layers have a Global ID column with GUIDs in them (both a Global ID and enabling editor
tracking is a requirement for supporting branch versioning)

•
•
•
•
•
•

Drag one of the FDS’s FCs into the map, then open its attribute table, looking for a Global ID
column. If there isn’t one, continue…
Remove all layers from the map
In Catalog, right click on the FDS, then select Manage > Add Global IDs
In Catalog, right click on the FDS, then select Manage > Enable Editor Tracking
In Catalog, right click on the Centerline_Sequence table, and add the Global IDs, and enableeditor tracking, same as above
Do this for any other FCs that are in your EGDB, if any

31. Enable branch versioning•••

In Catalog, in the Folders section, right click on your new EGDB
Click Geodatabase Connection Properties
In the Geodatabase Connection Properties dialog box, change Versioning Type from Traditional
to Branch, then Click OK

32. Register the EGDB contents as versioned• In Catalog, in your new EGDB, right click the FDS, then "Manage > Register as Versioned..."• Then right click the Centerline_Sequence table, then "Manage > Register as Versioned..."• Then right click any other FCs, then "Manage > Register as Versioned..."33. Create and symbolize your map
•
•
•
•
•

Start a new project in ArcGIS Pro with one new Map
Create a new database connection to where your EGDB is
Add the FDS to the map, and make it look the way you want.
Adding them to a group layer can help organize your map better.
Save the project

34. Publish web services•

Ensure in Pro that you are logged into an Enterprise portal that has ArcGIS Roads & Highways
installed and running (actually log into enterprise-ent with railadmin, because thetransportation server is federated to it.

•

Ensure that your Map Pro project contains only one LRS. If you have multiple LRSs to publish,
ensure they are each in their own Pro project. Also, edit the layer names to remove the fully
qualified database prefix. Just leave what you want the layer to be called.

••

In the Map, on the Share ribbon: click Web Layer > Publish Web Layer
In the Share as Web Layer dialog box
o General tab:
▪ Give it a name, summary, tags
▪ Reference registered data: Map Image radio button on, Feature check box on▪ Copy all data: leave off, so that the data stays in the DBMS, rather than copied
to the relational data store▪ Portal folder: whatever folder you want this to be in▪ Server and Folder: https://[your_server_domain]/arcgis, then whatever folder
you want it to be in• In my case, we use the utilities-transportation server, because that justhappens to be at this point the only server with LRS/R&H on it• This should be the from dropdown▪ Share with: for now, just the Portal, private just the railadmin usero Configuration tab – Left most icon
▪ Layers: should show as Map Image and Feature▪ Additional layers: no need for WMS or WFS▪ Capabilities: check on Linear Referencing and Version Managemento Configuration tab – Right most icon
▪ Instance Type: change to Dedicated instance, Min 2, Max 4
o Content tab:
▪ Under “My Content”, should show the portal folder your stuff is in▪ Under that should be a Map service with your layers underneath▪ Under that should be a Feature service with your layers underneatho Click “Analyze”

35. If during “Analyze”, you get errors about data sources not being registered with the server, thenright click, Register with the Server, then an "Add data store" dialog opens up. Give it Title, Tags, Portal
Folder, then Validate, then Create. Also errors about sequential IDs, set that up as a property of theMap. Some of the LRS object that were not registered as versioned (the locks tables)
After that’s done, click on “Manage the web layer” to go directly to the hosting server portal. Ensurethat the map image layer and feature layer are published, along with the data store
https://[your_server_domain]/server/manager/#--do this from any machine, even your own machine
Go into your server folder to ensure it’s running
Click on Capabilities to get the REST endpoints for LRSServer and the FeatureServer

36. Now let's create an Event Editor web app• The steps below are all covered thru this page here
https://enterprise.arcgis.com/en/roads-highways/latest/event-editor/configuring-the-event-editorweb-application.htm

•
•
•
•
•

Use File Explorer and go to your web server root. If you're using MS-IIS, then it's usuallyinetpub\wwwroot
Create a folder that will be your website
Go to C:\Program
Files\ArcGIS\LocationReferencing\Server11.1\Web\RoadsandHighways\RoadwayCharacteristics
Editor
Select all contents and copy
Go back in your inetpub\wwwroot\[your_website] folder, paste it all in

37. Create a Web Map••••

In a browser, go to you Enterprise portal and log in
In the Contents tab, in the folder you put the published web layers into, find the Map Service(not the feature service) and open its portal Item page.
Click the blue “Open in Map Viewer” button
Save your web map, giving it a title, tags, summary, then Save.