Skill Drill: Add a Time Cost Attribute to the Roads Layer

To calculate the travel time, in minutes, you will use the length of each road segment along with the speed limit. The road layer should have the length of each segment recorded in the Shape_Length field. However, since your have clipped the road layer, these values will need to be updated to account for any road segments that may have been altered during the Clip operation. To update the length values, use the Calculate Geometry option in the attribute table. If you will recall from previous courses, you can access Calculate Geometry by right clicking on the field name, Shape_Length. Make sure the values are saved in meters.

Note: If you can’t find the Shape_Length field, you can create your own by adding a new field in the attribute table. Then use Calculate Geometry to populate the field.

An image of the Calculate Geometry window in ArcMap.
Always use Calculate Geometry after any geoprocessing operation that alters the feature geometry.

The network allocation model requires a cost attribute with time units to be present in the network dataset. Create a new field in the attribute table of the clipped-roads layer. Name this field Minutes. This field will record the travel time, in minutes, for each road segment. In most cases, the road segments will have values of less than one minute travel time. Therefore, the field type should be either a float or a double. If you are ever unsure which, I recommend that you always choose the double field type since it will allow for a larger number if necessary.

An image of the Add Field window in ArcMap.
When adding a new field to the attribute table, the Double field type will allow for larger numbers with decimal places.

The road layer has two attributes that record the speed limit, AB_Speed, and BA_Speed. These attributes represent the speed limit, in miles per hour, for each direction. For consistency, use the AB_Speed in your calculation. Use the Field Calculator to compute the travel time and to populate the Minutes field. Your formula should factor in the AB_Speed (miles per hour) and the Shape_Length (meters) of each road segment to determine the travel time in minutes. If you will recall from previous courses, you can access Field Calculator by right-clicking on the field name, Minutes.

Coming up with the right formula will involve converting miles per hour to meters per minute. Then it requires using the length of the roads to determine the travel time in minutes.

An image of the Field Calculator window in ArcMap.
You can build complex functions to populate a field in the attribute table using the Field Calculator .

Once you have successfully calculated the minutes, you can verify the accuracy of your calculation by checking the travel time of a portion of G Street in Arcata, just before the on-ramp to HWY 101. Just west of the on-ramp, the travel time of the road segment on G Street is 1.059253 minutes. See the image below to compare the same road segment with your own data.

An image of G street selected in ArcMap
Use this road segment of G Steet to verify that your formula in the Field Calculator is correct. Click the image to view it in a larger size.