How to perform point on line event overlay


Overlaying two event tables is one way to analyze events. Events can be overlayed using a RouteMeasureEventGeoprocessor object.
The output event table can contain either the intersection or the union of the input tables. The union of the input tables splits all linear events at their intersections and writes them to the new event table. The intersection of the input events writes only overalapping events to the output event table.
 
A RouteMeasureEventGeoprocessor object supports line-on-line, point-on-line and point-on-point overlays.
When you union a point and a line event table, the resulting event table will contain linear events. When you intersect a point and a line event table, the resulting event table will contain point events.
The following diagram shows conceptually how point-on-line event overlay works for both the union and intersect options. Notice that zero length events are automatically kept when a union is performed.
 
 
In the code at the bottom of this sample, we will find the intersection of a point event table called ACCIDENTS which contains highway accident data and a linear event table called PAV_CRACK which describes pavement cracking. The results can be used to analyze the pavement characteristics of accident locations.
 
An event table containing information on accident locations, number of people injured and alcohol involvement.
 
An event table with data on the amount of pavement cracking on route 101.
 
This event table is the result of intersecting ACCIDENTS and PAV_CRACK.

How to use

  1. Paste the code into VBA.
  2. Modify the code to match your data paths, etc.
  3. Run the code.
[VBA]
Public Sub PointOnLineIntersect(sAccessWS As String, sPtEvents As String, sPtRIDField As String, sPtMeasureField As String, _
                                sLineEvents As String, sLineRIDField As String, sLineFromMeasureField As String, sLineToMeasureField As String, _
                                sOutEvents As String)
    
    '+++ sAccessWS - access workspace
    '+++ sPtEvents - input point event table
    '+++ sPtRIDField - Route identifier field for the point event table
    '+++ sPtMeasureField - Measure field for the point event table
    '+++ sLineEvents - overlay line event table
    '+++ sLineRIDField - Route identifier field for the line event table
    '+++ sLineFromMeasureField - From-measure field for the line event table
    '+++ sLineToMeasureField - To-measure field for the line event table
    
    
    On Error GoTo eh
    '+++ The input table and properties
    
    Dim pFact As IWorkspaceFactory
    Dim pFeatWS As IFeatureWorkspace
    Dim pInputTable As ITable
    Set pFact = New AccessWorkspaceFactory
    Set pFeatWS = pFact.OpenFromFile(sAccessWS, 0)
    Set pInputTable = pFeatWS.OpenTable(sPtEvents)
    
    Dim pInputProp As IRouteEventProperties2
    Dim pInputRMProp As IRouteMeasurePointProperties2
    Set pInputProp = New RouteMeasurePointProperties
    pInputProp.EventRouteIDFieldName = sPtRIDField
    Set pInputRMProp = pInputProp
    pInputRMProp.MeasureFieldName = sPtMeasureField
    
    '+++ The overlay table and properties
    
    Dim pOverlayTable As ITable
    Set pOverlayTable = pFeatWS.OpenTable(sLineEvents)
    
    Dim pOverlayProp As IRouteEventProperties2
    Dim pOverlayRMProp As IRouteMeasureLineProperties
    Set pOverlayProp = New RouteMeasureLineProperties
    pOverlayProp.EventRouteIDFieldName = sLineRIDField
    Set pOverlayRMProp = pOverlayProp
    With pOverlayRMProp
        .FromMeasureFieldName = sLineFromMeasureField
        .ToMeasureFieldName = sLineToMeasureField
    End With
    
    '+++ Create some output event properties.
    
    Dim pOutputProp As IRouteEventProperties
    Dim pOutputRMProp As IRouteMeasurePointProperties
    Set pOutputProp = New RouteMeasurePointProperties
    With pOutputProp
        .EventMeasureUnit = esriUnknownUnits
        .EventRouteIDFieldName = "rkey"
    End With
    Set pOutputRMProp = pOutputProp
    pOutputRMProp.MeasureFieldName = "location"
    
    '+++ Create a new table name for the output. We'll write the results out to the
    '+++ same workspace as the input event table
    
    Dim pDS As IDataset
    Dim pOutDSN As IDatasetName
    Dim pOutWSN As IWorkspaceName
    Set pDS = pFeatWS
    Set pOutWSN = pDS.FullName
    Set pOutDSN = New TableName
    Set pOutDSN.WorkspaceName = pOutWSN
    pOutDSN.Name = sOutEvents 'this table should not exist already
    
    
    '+++ Set up a RouteMeasureEventGeoprocessor
    
    Dim pRMEvtProc As IRouteMeasureEventGeoprocessor2
    Set pRMEvtProc = New RouteMeasureGeoprocessor
    With pRMEvtProc
        Set .InputEventProperties = pInputRMProp
        Set .InputTable = pInputTable
        Set .OverlayEventProperties = pOverlayRMProp
        Set .OverlayTable = pOverlayTable
    End With
    
    '+++ Perform the overlay
    
    Dim pOutTable As ITable
    Set pOutTable = pRMEvtProc.Intersect2(pOutputRMProp, True, pOutDSN, Nothing, "")
    
    GoTo endproc
eh:
    Dim lNum As Long, sSrc As String, sDesc As String
    lNum = Err.Number
    sSrc = Err.Source
    sDesc = Err.Description
    Err.Raise lNum, sSrc, sDesc
    
endproc:
    
End Sub






Additional Requirements
  • ArcEditor at 9.0; ArcView at 9.1 forward