Hi,
I am trying to create service areas in Python using the NAX library in ArcPy for ArcGIS Pro 2.7. I would like to make sure the locations snap to the road network, not unnamed parking lot lines / highways, etc. It seems the only way to create a query is with the CalculateLocations object, but there are no resources I can find to figure how to incorporate CalculateLocations with Load or the nax.ServiceArea objects.
Any suggestions would be appreciated.
# Create a network dataset layer and get hte desired travel mode
ap.nax.MakeNetworkDatasetLayer(nds,nd_layer_name)
nd_travel_modes = ap.nax.GetTravelModes(nd_layer_name)
travel_mode = nd_travel_modes['Driving']
# Instantiate a ServiceArea solver object
service_area = arcpy.nax.ServiceArea(nd_layer_name)
# Set properties
service_area.distanceUnits = ap.nax.DistanceUnits.Meters
service_area.travelMode = travel_mode
service_area.outputType = arcpy.nax.ServiceAreaOutputType.Polygons
service_area.geometryAtOverlap = arcpy.nax.ServiceAreaOverlapGeometry.Split
search_query=[['RoadsNetwork',"'STREET' IS NOT NULL And 'STREET' <> ''"]]
search_criteria=[['RoadsNetwork','SHAPE'],['NetworkDataSet_Junctions','NONE']]
search_tolerance = "200 Meters"
arcpy.nax.CalculateLocations(School,nds,search_tolerance,search_criteria=search_criteria,exclude_restricted_elements="EXCLUDE",search_query=search_query)
Impedance = [100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600]
for n in Impedance:
service_area.defaultImpedanceCutoffs = [n]
fm_fac = service_area.fieldMappings(ap.nax.ServiceAreaInputDataType.Facilities,True)
fm_fac["Name"].mappedFieldName = 'ScNumber'
# Load Inputs
service_area.load(arcpy.nax.ServiceAreaInputDataType.Facilities, School,field_mappings=fm_fac, append=False)
# Solve the analysis
result = service_area.solve()
# Export Feature Class
result.export(arcpy.nax.ServiceAreaOutputDataType.Polygons, os.path.join(OutputFD,"Schools_Ntwk_"+str(n)+"m"))
print('Calculated service area for {}-m service area buffer'.format(n))