08 Network Index

NETWORK INDEX
A network index directory, also known as NetworkDB, is a directory containing indexes for the network data on which you’re performing analysis. These indexes contain connectivity information for your network, and are automatically created and maintained by the Network Analyst the first time you solve a network problem. To set up your network connectivity properly you need to access this index directory and copy it to your road theme. This is done with an Avenue script. Important: You can perform network analysis without this step, but you will not be able to set travel costs, restricted turns or directions, see the sections below.

With the Project view active,
Scroll down and click on Scripts > Click New

Copy and Paste this script to the script window in ArcView (Use CTRL+V to paste):

‘ This script copies over node numbers from nodes.dbf and adds record
‘ numbers to the line theme feature table. It adds fields called RECORD#,
‘ FJUNCTION, and TJUNCTION to the line theme feature table. A network
‘ index directory must exist for the network theme before running this
‘ script.

‘ Get the view and the network theme. Substitute aViewName for the name
‘ of your view, and aThemeName for the name of your network theme.

aView = av.GetProject.FindDoc(“VIEW_NAME_HERE”)

aNetworkTheme = aView.FindTheme(“THEME_NAME_HERE”)
aNetworkThemeFTab = aNetworkTheme.GetFTab

‘ Get the nodes.dbf file, make the VTab object, and get its fields

aNetworkIndexDir = aNetworkTheme.AsString.Substitute(“shp”,”nws”)
aNodeFile = FN.Merge(aNetworkIndexDir, “nodes.dbf”)
aNodeVTab = VTab.Make(aNodeFile, false, false)
aFjunction = aNodeVTab.FindField(“Fjunction”)
aTjunction = aNodeVTab.FindField(“Tjunction”)

‘ Add Record#, Fjunction, Tjunction fields to network theme FTab


aRecordField = Field.Make(“Record#”,#FIELD_LONG,12,0)
aFjunctionField = Field.Make(“Fjunction”,#FIELD_LONG,12,0)
aTjunctionField = Field.Make(“Tjunction”,#FIELD_LONG,12,0)
aFieldList = {aRecordField,aFjunctionField,aTjunctionField}
aNetworkThemeFTab.SetEditable(True)
aNetworkThemeFTab.AddFields(aFieldList)

‘ Use nodes.dbf to populate Rec#, Fjunction, Tjunction

Count = 0
for each r in aNetworkThemeFTab
aFromNodeNumber = aNodeVTab.ReturnValueNumber(aFjunction,Count)

aToNodeNumber = aNodeVTab.ReturnValueNumber(aTjunction,Count)
aNetworkThemeFTab.SetValueNumber(aFjunctionField,r,aFromNodeNumber)
aNetworkThemeFTab.SetValueNumber(aTjunctionField,r,aToNodeNumber)
Count = Count + 1
aNetworkThemeFTab.SetValueNumber(aRecordField,r,Count)
end

aNetworkThemeFTab.SetEditable(False)

Replace
aView = av.GetProject.FindDoc(“aViewName”)
with
aView = av.GetProject.FindDoc(“View1″) or the name that you have given the view.
Replace
aNetworkTheme = aView.FindTheme(“aThemeName”)
with
aNetworkTheme = aView.FindTheme(“nonetwork”) or the name that you have given the theme.

Click Script > Compile; then Script > Run

Upon completion, the following fields have now been added to your road theme, see the attribute table: Record#, Fjunction, Tjunction.

Record# is the arc# that ArcView uses for network analysis, FJunction is the from-node and TJunction is the to-node, meaning arc # runs from node # to node #. Mind you, this is not the same as allowed travel direction; it’s just the topological ordering that was employed by ArcView when the network index was created.

If you accidentally delete the script from your project, you can retrieve it again from the ArcView Help documentation.