Posts Tagged ‘junction’
Creating a network dataset
This is post #2 in a three part series. It is meant to be read after Preparing your Data to Become a Network Dataset.
A network dataset can be created from a shapefile or a feature class. If you are creating one from a feature class, it needs to be in its own feature dataset. Make sure you have the Network Analyst extension checked on, then right click on your streetline shapefile or the feature dataset that holds your streetline feature class, and choose “New… Network Dataset”.
After you give it a name, you will have the option the set Connectivity. Select the connectivity policy that you decided on before.
If you have designated z-levels the way I described, the next screen you encounter will automatically have these elevation settings. Keep them.
I haven’t tackled turn modeling yet, so select “No” on the next screen unless you’ve figured that out. (In which case, do you want to do a guest post?)
Now you are at the Attributes screen. If you’ve designated one-way streets the way I described, they will already be set up as a Oneway Restriction attribute. In addition, you’ll have a RoadClass Descriptor Attribute. Network Analyst uses this attribute to make the wording for turn-by-directions read correctly. There are 5 categories:
1 Local Street
2 Highway
3 Ramp
4 Ferry
5 Roundabout
It is automatically configured to try to inspect your attribute table and pull out these categories, but there’s no guarantee it’s going to work right. You should look at the code to check. Select it and click on the Evaluators button. Then select the first one in the list and click on the Evaluator Properties button.
Here’s what appears in my Pre-Logic VB Script Code box:
rc = 1 'Local road
Select Case UCase([CFCC])
Case "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19"
rc = 2 'Highway
Case "A60", "A63"
rc = 3 'Ramp
Case "A65", "A66", "A68", "A69"
rc = 4 'Ferry
Case "A62"
rc = 5 'Roundabout
End Select
It is picking attributes out of my Census Feature Class Code (CFCC) column. But is it not classifying them in the same way my metadata says they should be. I have some evidence my metadata is out of date, so maybe the code knows better, but I can’t be sure. So, I replaced the code with this, which I am sure about:
If [FTYPE] = "FWY" Or [FTYPE] = "HWY" Then
rc = 2 'Highway
ElseIf [FTYPE] = "RAMP" Then
rc = 3 'Ramp
Else
rc = 1 'Local road
End If
I didn’t have anything that was obviously ferries or roundabouts. Make sure rc, or whatever variable you use, is in the “Value =” box below the code window. Make the same changes for the To-From direction as well.
Now it is time to create your Cost Attributes. Press the Add… button and create a Distance Attribute. Make sure the Usage Type is Cost and that you set the units and data type to match your length field. Uncheck the Use by Default box unless you don’t have information to create a Time attribute.
It will have a yellow exclamation point beside it until you press the Evaluators button and define how it should be calculated. Set the Type to Field and the Value to your length field for both directions.
Follow the same procedure to create a Time attribute, except this time set the units to Minutes and keep Use by Default checked on. When you get to the Evaluators screen, set the Type to Field and then click the Evaluator Properties button so you can enter an expression (unless there is already a time field in your attribute table). I used the expression ( [LENGTH] / [Speed] ) * 60 in the “Value =” box. This works if you have a field for length in miles, speed in miles per hour, and want time in minutes. Adjust accordingly.
Next create a Hierarchy attribute (Usage Type: Hierarchy). You will probably want to leave the Use by Default box checked, but I will leave that up to you. (These default settings can still be changed when you run scenarios later). If you created a new field for it, then calculate it using that. Otherwise you’ll have to code a classification expression like I did for the RoadClass attribute… only this time with categories 1-3.
Finally, if you thought of any potential restrictions to travel earlier, create Restriction attributes for them now. Create a different attribute for each type of Restriction. I set one: “Private”, for private roads and driveways, so I could avoid them if need be (like if I was driving a commercial vehicle). I didn’t use it by default because most of the time this won’t be an issue. Restriction attributes are based on a Boolean value (True or False) so my classification expression looks a little different:
Here’s my list of attributes in the end:
If you’ve done everything right thus far, you’ll have the option to configure driving directions. (It didn’t let me the first time around, I think because I didn’t create a Distance attribute). These are cool and you definitely want them! Click the Directions… button to see/change the settings. It’s pretty smart and gets everything right for me automatically. You can click anywhere to bring up drop-down menus and change things.
I didn’t have anything in my attribute table that helps with labeling highway shields (like route numbers). But I do have a field that says which city/county each road segment is in. So I pointed to that as the boundary field on the Boundary tab. Now, the driving directions will tell me if I cross over from one jurisdiction to another.
You’ll get a summary at the end, and then it’s time to click FINISH! Go ahead and Build when it prompts you. Then, add your new network dataset to ArcMap because it is time to play.
Stay tuned for installment #3: Doing network analysis
Tags: driving directions, junction, network analyst, VBA