Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to populate FNODE and TNODE fields for my roads dataset. I have an intersections point feature class that has unique ids, and I need each road segment to have an FNODE and TNODE value that corresponds to the intersection id. The roads are broken into segments at each intersection so that each segment only touches 2 intersection points. I thought that maybe Network Analyst generated these, but it doesn't look like it actually writes these values. Does anyone know how to generate these?

This dataset won't be used in Network Analyst - it will be used in a custom legacy add in that a client uses.

share|improve this question

1 Answer 1

Just figured out this in VBA..Before running this make backup(not well error handled)..first layer should be the Intersection point layer..second layer should be the road layer...start Edit..

The code spatially identifies the point features on the start and end points of every line feature and Updates the OBJECTID values to FNODE and TNODE fields.

Sub UpdateFromTo()
Dim pMxDoc As IMxDocument
Dim pMap As IMap

Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

Dim pointFtrLyr As IFeatureLayer
Set pointFtrLyr = pMap.Layer(0)

Dim lineFtrLyr As IFeatureLayer
Set lineFtrLyr = pMap.Layer(1)

Dim lineFC As IFeatureClass
Set lineFC = lineFtrLyr.FeatureClass
Dim fromNodeIndex As Integer
fromNodeIndex = lineFC.FindField("FNODE")
Dim toNodeIndex As Integer
toNodeIndex = lineFC.FindField("TNODE")

Dim pFI2 As IFeatureIndex2
Set pFI2 = New FeatureIndex

Set pFI2.FeatureClass = pointFtrLyr.FeatureClass
Set pFI2.OutputSpatialReference("Shape") = pMxDoc.FocusMap.SpatialReference
pFI2.Index Nothing, pointFtrLyr.AreaOfInterest

Dim m_IQ2 As IIndexQuery2
Set m_IQ2 = pFI2

Dim pID As New UID
pID = "esriEditor.Editor"
Dim pEditor As IEditor
Set pEditor = Application.FindExtensionByCLSID(pID)


Dim pLineCursor As IFeatureCursor
Set pLineCursor = lineFtrLyr.Search(Nothing, False)

Dim pLineFeature As IFeature
Set pLineFeature = pLineCursor.NextFeature

Dim foid As Long
Dim toid As Long
Dim fdist As Double
Dim tdist As Double

Do While Not pLineFeature Is Nothing

Dim pLine As IPolyline
Set pLine = pLineFeature.Shape
m_IQ2.NearestFeature pLine.FromPoint, foid, fdist

If Round(fdist, 0) = 0 Then

    pLineFeature.Value(pLineFeature.Fields.FindField("FNODE")) = foid

End If

m_IQ2.NearestFeature pLine.ToPoint, toid, tdist

If Round(tdist, 0) = 0 Then

    pLineFeature.Value(pLineFeature.Fields.FindField("TNODE")) = toid

End If

Set pLineFeature = pLineCursor.NextFeature

pEditor.StopOperation "Calculate FromTo Nodes"

MsgBox "Features updated!!"

End Sub
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.