Theo_E

Basic OD Cost Matrix script not working (error 000732)

Discussion created by Theo_E on May 21, 2012
Latest reply on May 21, 2012 by curtvprice
Dear all,

I've been using modelbuilder to create a basic model of an OD Cost Matrix analysis. I exported it to a python script to create script tool (code below). Unfortunately I keep getting the following error:

"ERROR 000732: Input network analysis layer: Dataset C:\GIS\databases\fullnetwork.gdb\fullnetwork\fullnetwork_ND does not exist or is not supported."

I've also tried "C:/GIS/databases/fullnetwork.gdb/fullnetwork/fullnetwork_ND" but i got the same error.

The model has 4 required parameters (script tool parameters):
- Network / Network Dataset / Input
- Origins / Feature Class / Input
- Destinations / Feature Class / Input
- NA_Output / Feature Class / Output

I really don't understand what I am doing wrong... any advice welcome :-)

Best regards,
Theo



[PHP]
# ---------------------------------------------------------------------------
# OD_COST_PYTHON_Brut3.py
# Created on: 2012-05-21 13:42:11.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: OD_COST_PYTHON_Brut3 <fullnetwork_ND__2_> <Origin_feature_points> <Destination_feature_points> <line_feature_output>
# Description:
# ---------------------------------------------------------------------------

# Set the necessary product code
# import arcinfo


# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("Network")

# Script arguments
fullnetwork_ND__2_ = arcpy.GetParameterAsText(0)
if fullnetwork_ND__2_ == '#' or not fullnetwork_ND__2_:
    fullnetwork_ND__2_ = "fullnetwork_ND" # provide a default value if unspecified
   
Origin_feature_points = arcpy.GetParameterAsText(1)
if Origin_feature_points == '#' or not Origin_feature_points:
    Origin_feature_points = "oioiuiuo_origins" # provide a default value if unspecified

Destination_feature_points = arcpy.GetParameterAsText(2)
if Destination_feature_points == '#' or not Destination_feature_points:
    Destination_feature_points = "oioiuiuo_origins" # provide a default value if unspecified

line_feature_output = arcpy.GetParameterAsText(3)
if line_feature_output == '#' or not line_feature_output:
    line_feature_output = "D:\\pythonproject\\premierpas\\databases\\scratch.gdb\\odout" # provide a default value if unspecified

# Local variables:
Destinations = "OD Cost Matrix\\Destinations"
OD_Cost_Matrix__3_ = Origin_feature_points
OD_Cost_Matrix__5_ = OD_Cost_Matrix__3_
OD_Cost_Matrix__2_ = OD_Cost_Matrix__5_
OD_Cost_Matrix__6_ = OD_Cost_Matrix__2_
Lines = OD_Cost_Matrix__6_
Lines__3_ = Lines
Lines__4_ = Lines__3_
Solve_succeeded = OD_Cost_Matrix__2_
Origins = "OD Cost Matrix\\Origins"
OD_Cost_Matrix = fullnetwork_ND__2_
OD_Cost_Matrix__4_ = OD_Cost_Matrix

# Process: Make OD Cost Matrix Layer
arcpy.MakeODCostMatrixLayer_na(fullnetwork_ND__2_, "OD Cost Matrix", "Length", "", "", "", "ALLOW_UTURNS", "", "NO_HIERARCHY", "", "STRAIGHT_LINES")

# Process: Add Field to Analysis Layer
arcpy.AddFieldToAnalysisLayer_na(OD_Cost_Matrix, "Origins", "OriginAddressID", "LONG", "", "", "", "", "NULLABLE")

# Process: Add Locations
arcpy.AddLocations_na(OD_Cost_Matrix__4_, "Origins", Origin_feature_points, "Name OBJECTID #;TargetDestinationCount # #;CurbApproach # 0;Cutoff_Length # #;OriginAddressID OBJECTID #;SourceID SourceID #;SourceOID SourceOID #;PosAlong PosAlong #;SideOfEdge SideOfEdge #", "5000 Meters", "", "NetworkFull SHAPE;fullnetwork_ND_Junctions NONE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE", "NetworkFull #;fullnetwork_ND_Junctions #")

# Process: Add Field to Analysis Layer (2)
arcpy.AddFieldToAnalysisLayer_na(OD_Cost_Matrix__3_, "Destinations", "DestinationAddressID", "LONG", "", "", "", "", "NULLABLE")

# Process: Add Locations (2)
arcpy.AddLocations_na(OD_Cost_Matrix__5_, "Destinations", Destination_feature_points, "Name OBJECTID #;CurbApproach # 0;DestinationAddressID OBJECTID #;SourceID SourceID #;SourceOID SourceOID #;PosAlong PosAlong #;SideOfEdge SideOfEdge #", "5000 Meters", "", "NetworkFull SHAPE;fullnetwork_ND_Junctions NONE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "NetworkFull #;fullnetwork_ND_Junctions #")

# Process: Solve
arcpy.Solve_na(OD_Cost_Matrix__2_, "SKIP", "CONTINUE")

# Process: Select Data
arcpy.SelectData_management(OD_Cost_Matrix__6_, "Lines")

# Process: Join Field
arcpy.JoinField_management(Lines, "DestinationID", Destinations, "OBJECTID", "DestinationAddressID")

# Process: Join Field (2)
arcpy.JoinField_management(Lines__3_, "OriginID", Origins, "OBJECTID", "OriginAddressID")

# Process: Copy Features
arcpy.CopyFeatures_management(Lines__4_, line_feature_output, "", "0", "0", "0")
[/PHP]

Outcomes