I want to calculate the OD Cost Matrix in ArcMap 10.3.1 using the ArcPy package. When running the arcpy.Solve_na
, the Python console prints a lot of warning messages. After a while, ArcMap crashes, resulting in the need to close it. I have tried some methods, but they didn't work. Code, warning messages and methods are below:
Code
POI = r"...path\poi"
other_Pt = r"...path\poi"
# Local variables:
TP_pi1_Layer1 = "TP_pi1_Layer1"
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(POI, TP_pi1_Layer1, Expression_mrt, "", "OBJECTID OBJECTID HIDDEN NONE;Shape Shape HIDDEN NONE;Name Name VISIBLE NONE;City City HIDDEN NONE;Town Town HIDDEN NONE;Level1 Level1 HIDDEN NONE;Level2 Level2 HIDDEN NONE;Level3 Level3 VISIBLE NONE;Id Id HIDDEN NONE")
# Local variables:
OD_Cost_Matrix = "OD Cost Matrix"
OD_Cost_Matrix__4_ = OD_Cost_Matrix
OD_Cost_Matrix__5_ = OD_Cost_Matrix__4_
# Process: Make OD Cost Matrix Layer
arcpy.MakeODCostMatrixLayer_na(NetworkDataset_ND, "OD Cost Matrix", "Length", "", "1", "", "ALLOW_UTURNS", "", "NO_HIERARCHY", "", "NO_LINES", "")
# Process: Add Locations
arcpy.AddLocations_na(OD_Cost_Matrix, "Origins", other_Pt, "", "200 Meters", "", "NetworkDataset_ND_Junctions NONE;Twn5000rc_polyline1 SHAPE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE", "NetworkDataset_ND_Junctions #;Twn5000rc_polyline1 #")
# Process: Add Locations
arcpy.AddLocations_na(OD_Cost_Matrix__4_, "Destinations", TP_pi1_Layer1, "Name Name #", "200 Meters", "", "NetworkDataset_ND_Junctions NONE;Twn5000rc_polyline1 SHAPE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE", "NetworkDataset_ND_Junctions #;Twn5000rc_polyline1 #")
# Process: Solve
arcpy.Solve_na(OD_Cost_Matrix__5_, "SKIP", "TERMINATE", "")
warning messages Those warning messages don't stop the code from running, but when the number of warning messages exceeds 30,000 lines, ArcMap crashes.
I tried those methods, but they didn't work.:
1.
arcpy.SetLogHistory(False)
import warnings
def handle_warning():
pass
warnings.showwarning = handle_warning
import warnings
warnings.filterwarnings("ignore")
arcpy.SetSeverityLevel(1)
print("Severity is set to : {0}".format(arcpy.GetSeverityLevel()))
try:
arcpy.Solve_na(OD_Cost_Matrix__5_, "SKIP", "TERMINATE", "")
except arcpy.ExecuteWarning:
pass
except arcpy.ExecuteError:
pass
Has anyone solved this problem?