Add Costs
The next stage is to define the Travel Attributes, such as the modes of travel, costs and restrictions. Following the Esri tutorial, start with defining the Costs, which can be accessed from the ‘Travel Attributes’ section of the Network Dataset Properties dialog box menu, and then select the ‘Costs’ tab.
Costs are time or distance values that describe the impedance associated with travelling along a network edge. Route planning and network analysis often involve the minimization of costs along a network to find the best route.
Costs - Distance
The Distance cost tells the network the length of each edge of the network. As mentioned previously, depending on how the OS MRN feature dataset has been created, the attribution associated with the geometry of a transportlink may be different from how it is described in this document.
Set up a ‘Kilometers’ Distance cost as per the settings shown in the Network Dataset Properties screenshot below. This uses a Field Script that divides the length attribute value (which is in metres) by 1000 to give a value in kilometres. The Field Script settings can be accessed by double clicking in the Value field and then clicking on the symbol.
To use an attribute value in a function or field script, Network Analyst requires the use of exclamation marks either side of the attribute name. So, to use the length attribute value in a field script, use the following format, as seen in the field script in the Network Dataset Properties screenshot below: !length!
Note use of exclamation marks either side of the attribute field name
Costs - Minutes
OS MRN is multi-modal by definition, so there is no discrete time value in the data that represents the time taken to traverse the transportlink for a particular travel mode as it will depend on the mode of travel. It is therefore necessary to create a Minutes cost for each mode of transport.
Costs - Minutes - Driving
New costs can be added via the Menu button in the top right of the Costs tab (icon with three horizonal bars). Click the Menu button in the upper right corner and click on New.
In the Properties section, give the new cost a name such as ‘Driving_Minutes’, set the Units field to ‘Minutes’, and keep the Data Type as ‘double’.
In the Evaluators section, change the Type to ‘Field Script’ for both the Along and Against directions as scripts are needed to calculate travel times as functions of distance and speed. Due to the way the speed data is represented in OS MRN, particularly for one-way links, with maximum and average speeds for both along and against directions, fairly complex scripts are needed to account for the different combinations and avoid the situation where the script is pulling through NULL values in the formula to calculate time. The Field Script Evaluator Properties screenshots below show the field scripts used.
Field script text code snippets
Code snippets containing the field script texts which can be copied and pasted into the field script dialogue boxes are included in the associated markdown file “MRN code snippets.md” hosted on the OS MRN Downloads page.
OS MRN also contains a number of conditional average speed data information with different average speeds for different times of day for which this simple approach will not apply, unless additional driving minutes fields were added for all the different time slots for which different speeds are provided. At this stage, it is not clear how to apply time of day conditionality within Esri Network Analyst.
Next, in the Turns section of the Driving_Minutes cost set-up screen, change the Type for the turns source to ‘Turn Category’, double click on the Value field and click on the function symbol on the right to set the turn categories as shown in the Turn Category evaluator window shown below. These will be revisited later once a network hierarchy has been established, as there will be more turn types available then.
The completed Driving_Minutes cost screen should now look like the Network Dataset Properties window below. Don’t worry about the warning sign against the Turns evaluators – this will be addressed when we add hierarchy attributes to the Network Dataset.
Costs - Minutes - Walking
There is no speed data in the OS MRN data specifically for walking, so an assumed average walking speed of 5kph is used. There is also no complication associated with one-way transportlink features, so a simple formula in a field script can be used for Along and Against directions of travel, as shown in the Network Dataset Properties screenshot below. The formula divides the length of the network link in metres by the assumed speed in kph multiplied by 1000 and divided by 60 to get metres per minute.
In line with the Esri tutorial highlighted on the Using OS MRN with Esri Network Analyst page of this guide, only costs for driving and walking have been created. Equivalent costs would need to be made for each other mode of transport, assuming an average speed for each which will be applied to all transportlink features for that mode of transport.
Last updated
Was this helpful?