ODCostMatrix Lines output is empty using arcpy.nax?

08-30-2019 06:52 PM
New Contributor

After reading through the documentation of the new arcpy.nax library, specifically ODCostMatrix and related objects, I attempted to port over a script that was using arcpy.na. Unfortunately the Lines output remains stubbornly blank using mostly default inputs, and I am having trouble diagnosing why that is. I've tried changing several of the inputs but none of them seem to fill the Lines output.

Here is the portion of my script using ODCostMatrix:

od = arcpy.nax.OriginDestinationCostMatrix(NETWORK)
od.distanceUnits = arcpy.nax.DistanceUnits.Meters
od.defaultDestinationCount = 1
# CENT_TEMP is a feature class of points, drawn from the centroids of polygons
# DESTS is also a feature class of points
od.load(arcpy.nax.OriginDestinationCostMatrixInputDataType.Origins, CENT_TEMP)
od.load(arcpy.nax.OriginDestinationCostMatrixInputDataType.Destinations, DESTS)
od_result = od.solve()

# later on in the code...
orig_dist = {}
line_search = arcpy.nax.OriginDestinationCostMatrixOutputDataType.Lines
OD_LINES = arcpy.env.workspace + r"/od_lines"
od_result.export(line_search, OD_LINES)
with arcpy.da.SearchCursor(OD_LINES, ["OriginOID", "DestinationOID", "Shape_Length", "Total_Distance"]) as sCursor:
    # ... does not work because OD_LINES is empty

Here is the description of my network. It was a pre-existing network, and I added the "Basic" travel mode so it would work with arcpy.nax.

Data Type: File Geodatabase Network Dataset

Feature Dataset: RDIDataSet1
Network: RDINetwork1
Dataset Version: 10.0

Build Status: Built
  The network dataset has been built.
  Build Time: Fri Aug 30 18:39:27 2019

  Edges: 5460
  Junctions: 2179

  Edge Sources:
  Junction Sources:

    Streets1 edges use End Point connectivity policy.
  Elevation Model: Elevation Fields

Travel Attributes:
  Travel Modes:
    Default Travel Mode: Basic
    Travel Mode: Basic
        Collection of network dataset settings that define actions that are allowed on the
        network and how the actions can be performed.

      Type: Automobile
      Uses Costs:
        Impedance: RouteDistance
      Allowed U-Turns: All
    Cost: RouteDistance
      Units: Meters
      Data Type: double
      Used By Travel Modes:
        Impedance: Basic
        Streets1 (Bi-Directional): Field Script (VBScript)
          Value: [Shape_Length]

The full script is attached. Any help is appreciated!

0 Kudos
0 Replies