I'm trying to run OD Cost Matrix function for my term project and i run into a problem. I have 2566 origins and 3 destinations and I am trying to calculate distance base origin cost matrix from every origin point to every destination point but as you can see in figure, only 43 lines appeared. The problem is not about my network. I used the default settings for building the network. The error message is : Warning: No "Destinations" found for "Location 1" in "Origins" for every origin. I could not figure what the problem is.
[GIS] OD Cost Matrix does not work from every origin to every destination
arcgis-desktopnetwork-analyst
Related Solutions
I would put the core of your code within a "for" loop. Something like this:
for year in range(1999,2005): #python doesn't include 2005 here and will only go up to 2004
outNALayer_Year = 'outNALayer'+str(year)
Pas_Lyr_Year = 'Pas_Lyr'+str(year)
arcpy.MakeFeatureLayer_management (inOrgins, Pas_Lyr_Year)
arcpy.SelectLayerByAttribute_management (Pas_Lyr_Year, "NEW_SELECTION", " f_aar = str(year) ")
#Create a new OD Cost matrix layer.
arcpy.MakeODCostMatrixLayer_na(inNetworkDataset, outNALayer_Year, "Minutes", "", "", "Minutes")
#Load the locations as origins.
arcpy.AddLocations_na(outNALayer_Year, "Origins", "Pas_Lyr_Year", "Name f_aar #","1000 Meters", "SYKEHUS")
#Load the locations as destinations
arcpy.AddLocations_na (outNALayer_Year, "Destinations", inDestinations, "Name SYKEHUS #","1000 Meters", "SYKEHUS")
#Solve the OD cost matrix layer
arcpy.Solve_na(outNALayer_Year)
#Save the solved OD cost matrix layer as a layer file on disk with relative paths
arcpy.SaveToLayerFile_management(outNALayer_Year, outLayerFile_Year,"RELATIVE")
Anytime you reference outNALayer_1999, outNALayer_2000 and so on, replace it with outNALayer_Year. Same goes for Pas_Lyr1999, etc.
Note, I haven't tested this, but that's the logic I would use.
So here are the code and summary of the aforementioned bugs, as requested by @Chris W. Basically they seem to refer to the same issue and to have the same cause, i.e. a problem with the OD cost algorithm.
- NIM094092 - The OD cost matrix analysis in ArcMap returns different travel time results for one origin if another origin is present.
- NIM060948 - Time and length returned from solving OD Cost Matrix problem varies between the same origin and destination depending on the number and location of input origin points.
- BUG-000084762 - When solving an OD Cost Matrix for a large network dataset using Hierarchy, erroneous results are returned in a small number of combinations where the route connecting an Origin and a Destination is of a longer duration than any other route from the same Origin and Destination that diverts through a third location.
They've been found between versions 10.0 and 10.2.2 and are all assigned.
As I commented before, an alternative could be to use Closest facility analysis (in an automated process) to get a similar output and see if the results are more reliable. I suppose the feasibility of this depends largely of the number of origin and destination points.
Best Answer
I think it is a network problem.
When that happens to me it's usually due to the restrictions settings not allowing a path from an origin to any destination. As a diagnostic tool, try running 1 origin to 1 destination that you know failed (as in "No Destinations Found") as a Closest Facility model in Network Analyst instead of OD Cost Matrix. That way, if it's failing in OD Cost Matrix, you can see the actual path it's supposed to take in Closest Facility, which should point you to where in the process it is failing. If Closest Facility cannot draw a polyline from your origin to your destination, it's a network dataset settings issue. If you do get a path drawn, it's your OD Cost Matrix analysis settings. You may also want to revisit the settings you chose when loading locations--that could be affecting how your origins and destinations snapped to the network to begin with.