How to dissolve events


Dissolving events combines records in a linear event table if they are on the same route and have the same value for the dissolve item(s). Dissolving events is useful for breaking up large event tables (many fields) into many smaller tables. Only the event key item, measure items and dissolve item(s) are written to the resulting event table.
Dissolving events produces different results than concatenating events (see Concatenate Events sample). You can only dissolve line or point event tables.
 
The following diagram demonstrates the conceptual difference between dissolving and concatenating line events.
 
 
The code at the bottom of this sample shows how to dissolve a linear event table. The output table will have only those records that have the same route key and different number of lanes.
 
An event table called PAV.
 
The result of dissolving the PAV table using the Lanes as the dissolve field.

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 DissolveEvents(sAccessWS As String, sEventTable As String, sRouteIDField As String, _
                          sFromMeasureField As String, sToMeasureField As String, sOutEventTable As String, sDissolveField As String)
    
    
    '+++ VARIABLES
    '+++ sAccessWS - access workspace
    '+++ sEventTable - event table
    '+++ sRouteIDField - route ID field
    '+++ sFromMeasureField - the from-measure field
    '+++ sToMeasureField - the to-measure field
    '+++ sOutEventTable - the output event table
    '+++ sDissolveField - field to dissolve on
    
    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(sEventTable)
    
    Dim pInputProp As IRouteEventProperties
    Dim pInputRMProp As IRouteMeasureLineProperties
    Set pInputProp = New RouteMeasureLineProperties
    With pInputProp
        .EventMeasureUnit = esriUnknownUnits
        .EventRouteIDFieldName = sRouteIDField
    End With
    Set pInputRMProp = pInputProp
    With pInputRMProp
        .FromMeasureFieldName = sFromMeasureField
        .ToMeasureFieldName = sToMeasureField
    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 pTempDS As IDataset
    Dim pTempWs As IWorkspace
    Dim pOutDSN As IDatasetName
    Dim pOutWSN As IWorkspaceName
    
    Set pTempDS = pInputTable
    Set pTempWs = pTempDS.Workspace
    Set pOutWSN = New WorkspaceName
    pOutWSN.ConnectionProperties = pTempWs.ConnectionProperties
    If pTempWs.Type = esriRemoteDatabaseWorkspace Then
        pOutWSN.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory.1"
    ElseIf pTempWs.Type = esriLocalDatabaseWorkspace Then
        pOutWSN.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory.1"
    Else
        pOutWSN.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory.1"
    End If
    Set pOutDSN = New TableName
    Set pOutDSN.WorkspaceName = pOutWSN
    pOutDSN.Name = sOutEventTable
    
    
    '+++ Create some output event properties.
    
    Dim pOutputProp As IRouteEventProperties2
    Dim pOutputRMProp As IRouteMeasureLineProperties
    Set pOutputProp = New RouteMeasureLineProperties
    With pOutputProp
        .EventMeasureUnit = esriUnknownUnits
        .EventRouteIDFieldName = sRouteIDField
    End With
    Set pOutputRMProp = pOutputProp
    With pOutputRMProp
        .FromMeasureFieldName = sFromMeasureField
        .ToMeasureFieldName = sToMeasureField
    End With
    
    
    '+++ Set up a RouteMeasureEventGeoprocessor
    
    Dim pRMEvtProc As IRouteMeasureEventGeoprocessor2
    Set pRMEvtProc = New RouteMeasureGeoprocessor
    With pRMEvtProc
        Set .InputEventProperties = pInputRMProp
        Set .InputTable = pInputTable
    End With
    
    '+++ Perform the dissolve on one field
    
    Dim pOutTable As ITable
    Set pOutTable = pRMEvtProc.dissolve2(pOutputRMProp, sDissolveField, pOutDSN, Nothing, "")
    
    '+++ It is possible to dissolve on multiple fields
    'Dim sFlds(1) As String
    'sFlds(0) = "lanes"
    'sFlds(1) = "cracks"
    'Set pOutTable = pRMEvtProc.dissolve2(pOutputRMProp, sFlds, 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