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 overalpping events to the output event table.
A RouteMeasureEventGeoprocessor object supports line-on-line, point-on-line and point-on-point overlays.
When you overlay two linear event tables, the result may have zero length events created. By setting IRouteMeasureEventGeoprocessor::KeepZeroLengthLineEvents appropriately, you can determine whether you would like the resulting event table to contain zero length events.
When we do an overlay, we automatically do a dissolve on the output event table. See Dissolve Events sample.
The following diagram shows conceptually how line-on-line event overlay works for both the union and intersect options.
In the code at the bottom of this sample, we will find the union of a linear event table called PAV_CRACK which describes pavement cracking, and another linear event table called PAV_RESURFACE which contains resrufacing dates. The results can be used to find the characteristics of the oldest paved sections.
An event table with data on the amount of pavement cracking on route 101
An event table containing resurfacing dates for portions of route 101
This event table is the union of the event tables PAV_CRACK and PAV_RESURFACE. The data shows that the stretch of route 101 from measure 167.4 to 182.8 is the most cracked and has the oldest surface.
How to use
- Paste the code into VBA.
- Modify the code to match your data paths, etc.
- Run the code.
Public Sub LineOnLineUnion(sAccessWS As String, sInputEvents As String, sInputRIDField As String, sInputFromMeasureField As String, _
sInputToMeasureField As String, sOverlayEvents As String, sOverlayRIDField As String, sOverlayFromMeasureField As String, _
sOverlayToMeasureField As String, sOutEventTable As String)
'+++ VARIABLES
'+++ sAccessWS - access workspace
'+++ sInputEvents - the input event table
'+++ sInputRIDField - the Route identifier field for the input event table
'+++ sInputFromMeasureField - the From-measure field for the input event table
'+++ sInputToMeasureField - the To-measure field for the input event table
'+++ sOverlayEvents - the overlay event table
'+++ sOverlayRIDField - the Route identifier field for the overlay event table
'+++ sOverlayFromMeasureField - the From-measure field for the overlay event table
'+++ sOverlayToMeasureField - the To-measure field for the overlay event table
'+++ sOutEventTable - the output 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(sInputEvents)
Dim pInputProp As IRouteEventProperties2
Dim pInputRMProp As IRouteMeasureLineProperties
Set pInputProp = New RouteMeasureLineProperties
With pInputProp
.EventMeasureUnit = esriUnknownUnits
.EventRouteIDFieldName = sInputRIDField
End With
Set pInputRMProp = pInputProp
With pInputRMProp
.FromMeasureFieldName = sInputFromMeasureField
.ToMeasureFieldName = sInputToMeasureField
End With
'+++ The overlay table and properties
Dim pOverlayTable As ITable
Set pOverlayTable = pFeatWS.OpenTable(sOverlayEvents)
Dim pOverlayProp As IRouteEventProperties2
Dim pOverlayRMProp As IRouteMeasureLineProperties
Set pOverlayProp = New RouteMeasureLineProperties
With pOverlayProp
.EventMeasureUnit = esriUnknownUnits
.EventRouteIDFieldName = sOverlayRIDField
End With
Set pOverlayRMProp = pOverlayProp
With pOverlayRMProp
.FromMeasureFieldName = sOverlayFromMeasureField
.ToMeasureFieldName = sOverlayToMeasureField
End With
'+++ Create some output event properties.
Dim pOutputProp As IRouteEventProperties2
Dim pOutputRMProp As IRouteMeasureLineProperties
Set pOutputProp = New RouteMeasureLineProperties
With pOutputProp
.EventMeasureUnit = esriUnknownUnits
.EventRouteIDFieldName = sOverlayRIDField
End With
Set pOutputRMProp = pOutputProp
With pOutputRMProp
.FromMeasureFieldName = sOverlayFromMeasureField
.ToMeasureFieldName = sOverlayToMeasureField
End With
'+++ Create a new table name for the output. We'll write the results out to the
'+++ same workspace as the input event table
Dim pOutDSN As IDatasetName
Dim pOutWSN As IWorkspaceName
Dim pTempDS As IDataset
Set pTempDS = pFeatWS
Set pOutWSN = pTempDS.FullName
Set pOutDSN = New TableName
Set pOutDSN.WorkspaceName = pOutWSN
pOutDSN.Name = sOutEventTable '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
.KeepZeroLengthLineEvents = True
End With
'+++ Perform the overlay
Dim pOutTable As ITable
Set pOutTable = pRMEvtProc.Union2(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