# Process: Cost Distance arcpy.gp.CostDistance_sa(destValue, weighted_Raster, "distance_Raster", "", 'backlink_Raster') # Process: Cost Path Least_Cost_Path = arcpy.gp.CostPath_sa(originValue,"distance_Raster", "backlink_Raster", os.path.join(savepath + "\\Results.gdb" + "\\lcp_" + str(count)), "EACH_CELL", "OBJECTID") global count while count < 3: # Local variables: End_Pts = 'End_Pts' Output_polyline_features = 'Output_polyline_features' End_Pts_Raster = 'End_Pts_Raster' Least_Cost_Route = 'Least_Cost_Route' Reclass_rast1 = 'Reclass_rast1' # Process: Raster to Polyline arcpy.RasterToPolyline_conversion(Least_Cost_Path, Output_polyline_features, "ZERO", "0", "SIMPLIFY", "") # Process: Feature Vertices To Points arcpy.FeatureVerticesToPoints_management(Output_polyline_features, End_Pts, "BOTH_ENDS") # Process: Point to Raster arcpy.PointToRaster_conversion(End_Pts, "", End_Pts_Raster, "MOST_FREQUENT", "NONE", Least_Cost_Path) # Process: Raster Calculator arcpy.gp.RasterCalculator_sa("SetNull(~IsNull("%End_Pts_Raster%"), \"%Least_Cost_Path%\")", Least_Cost_Route)
arcpy.gp.RasterCalculator_sa("SetNull(~IsNull("%End_Pts_Raster%"), \"%Least_Cost_Path%\")", Least_Cost_Route)
Solved! Go to Solution.
arcpy.gp.RasterCalculator_sa("SetNull(~IsNull("%End_Pts_Raster%"), \"%Least_Cost_Path%\")", Least_Cost_Route)
from arcpy.sa import * while .... ... eptras = Raster(End_Pts_Raster) LCostPth = Raster(Least_Cost_Path) LCR = SetNull( ~ IsNull(eptras), LCostPth) LCR.save("lcr{0}".format(count) count -= 1
arcpy.gp.RasterCalculator_sa("SetNull(~IsNull("%End_Pts_Raster%"), \"%Least_Cost_Path%\")", Least_Cost_Route)
from arcpy.sa import * while .... ... eptras = Raster(End_Pts_Raster) LCostPth = Raster(Least_Cost_Path) LCR = SetNull( ~ IsNull(eptras), LCostPth) LCR.save("lcr{0}".format(count) count -= 1
# Returns a value of 1 where End_Raster is NoData and 0 End_Raster points. isNull1 = IsNull(End_Raster) isNull1.save("isNull1_{0}".format(count)) #Returns LCP minus the end points # setNull1 = SetNull(isNull1,get_LCP(count),"Value = 0") setNull1.save("setNull1_{0}".format(count))