I am trying to use the arcpy.nax.LocationAllocation() method to solve location-allocation for dozens of different scenarios. I have a demand points layer that contains a Cutoff_Minutes field. This field is populated for each of the 23,419 records within my demand points layer. However, when trying to call loc_alloc.solve() I'm getting the following error:
"A default cutoff is required, or a cutoff must be present for every entry in 'Demand Points'"
I have quadruple-checked my demand points layer and the Cutoff_Minutes field does not contain any NULL or missing values. I think I'm missing a way to tell the loc_alloc object how to use this field instead of the default value, which I am intentionally leaving NULL.
Any insight is appreciated!
# An example showing how to perform location-allocation analysis using inputs from feature classes.
import arcpy
arcpy.CheckOutExtension("network")
nds = "C:/data/NorthAmerica.gdb/Routing/Routing_ND"
nd_layer_name = "Routing_ND"
input_facilities = "C:/data/io.gdb/Facilities"
input_demand_points = "C:/data/io.gdb/DemandPoints"
output_lines = "C:/data/io.gdb/AllocationLines"
# Create a network dataset layer and get the desired travel mode for analysis
arcpy.nax.MakeNetworkDatasetLayer(nds, nd_layer_name)
nd_travel_modes = arcpy.nax.GetTravelModes(nd_layer_name)
travel_mode = nd_travel_modes["Driving Time"]
# Instantiate a LocationAllocation solver object
loc_alloc = arcpy.nax.LocationAllocation(nd_layer_name)
# Set properties
loc_alloc.travelMode = travel_mode
loc_alloc.travelDirection = arcpy.nax.TravelDirection.ToFacility
loc_alloc.problemType = arcpy.nax.LocationAllocationProblemType.MaximizeCoverage
loc_alloc.timeUnits = arcpy.nax.TimeUnits.Minutes
# loc_alloc.defaultImpedanceCutoff = 15
loc_alloc.lineShapeType = arcpy.nax.LineShapeType.StraightLine
# Load inputs
loc_alloc.load(arcpy.nax.LocationAllocationInputDataType.Facilities, input_facilities)
loc_alloc.load(arcpy.nax.LocationAllocationInputDataType.DemandPoints, input_demand_points)
# Solve the analysis
result = loc_alloc.solve()
# Export the results to a feature class
if result.solveSucceeded:
result.export(arcpy.nax.LocationAllocationOutputDataType.Lines, output_lines)
else:
print("Solve failed")
print(result.solverMessages(