Restricting all solvers in Network Analyst from traversing specific roads in a network dataset is common practice when the road has been closed but still needs to remain part of the network dataset. Examples include roads that are closed or severely slowed due to construction, but will be opened at some point in the future.
This method is meant to replace placing a barrier on the restricted roads every time a solver is created. Once this method has been performed, the new field 'Restricted' can be set to True or False to stop any solver using the network dataset from traversing the specified road. Instructions provided describe how to restrict streets in both directions while keeping them in a network dataset.
This article assumes that the Network Dataset has already been created and the streets now need to be restricted. The procedure works with a new network dataset, but the steps necessary for creating a new network only are not included in this article.
Please see the knowledge base article located in the Related Information section below on creating a new network dataset.
- Open ArcMap. Add the reference feature class used to create the network dataset that contains the features to be restricted.
- Right-click the feature class in the Table of Contents > Open Attribute Table.
- In the Attribute table, click Options > Add New Field. Set the name to 'Restrict' without quotes, and set the type to Text. Click Ok. Minimize the Attribute table.
- Use the Select Tool to select all of the roads that need to be restricted in both directions.
- Once the roads are selected, open the Attribute table again. Right-click the field header for 'Restrict' > Field Calculator.
- Enter 'Y' with quotes into the text box. Make sure that 'Calculate Selected Features Only' is checked on. Click Ok. This should populate all of the selected features with a Y.
- In the Attribute table, click Options > Switch Selection. Repeat Steps 5 and 6, except calculate these selected features with an N. All of the features should have either a Y or N in the 'Restrict' field. There should not be any quotes showing in this field. Close ArcMap.
- Open ArcCatalog. Navigate to the feature dataset containing the network dataset in the Table of Contents. Right-click the network dataset, click Properties and then click the Attribute tab.
- In the Attribute tab, click Add. Set the name to 'Restricted' and set the type to 'Restriction'. Click Ok.
- Select the new attribute 'Restricted' in the Attribute tab, and click Evaluators.
- Set the Type to field for both the To-From and From-To directions.
- Select one of the directions and click the Evaluator Properties button (Icon on the right with the pointing hand under the X).
- In the Field Evaluators dialog box, copy and paste the following syntax into the upper box under Pre-Logic VB Script Code:
restricted = False
Select Case UCase([Restrict])
Case "Y": restricted = True
- Enter: 'restricted' without quotes in the lower box under 'Value ='. Click Ok. Click Apply and Ok.
- Repeat Steps 12-14 with the other direction so both To-From and From-To have the Pre-Logic VB Script.
- Click Apply and Ok. Then build the network again to apply the changes. The streets with a Y in the Restrict field should be restricted.
- In the future, to toggle if a road is restricted, change the Y to N or vice versa, and then rebuild the network.