flowAccGrd = "flow_acc" flowDirGrd = "flow_dir" somaExp = "streamlink(con(" + flowAccGrd + " > 500, 1, setnull(1)), " + flowDirGrd + ")" streamLinkGrd = "stream_link" gp.SingleOutputMapAlgeba_sa(somaExp, streamLinkGrd)
flowAccGrd = "flow_acc" flowDirGrd = "flow_dir" streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccGrd, 1, arcpy.sa.SetNull(1,1), "VALUE >= 500")), flowDirGrd) streamLinkGrd = "stream_link" streamLinkTmp.save(streamLinkGrd)
Solved! Go to Solution.
flowAccGrd = arcpy.Raster("C:\\example\\flowaccgrd") ... streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccGrd > 500, 1), flowDirGrd) ...
flowAccGrd = arcpy.Raster("C:\\example\\flowaccgrd") ... streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccGrd > 500, 1), flowDirGrd) ...
#Process: Run a Fill fillTmp = arcpy.sa.Fill(clipDem, "") fillGrd = areaIdFolderPath + "\\fill" fillTmp.save(fillGrd) #Process: FlowDir flowDirTmp = arcpy.sa.FlowDirection(fillGrd, "", "") #NOTE: I am using the fillGrd variable not the the fillTmp variable: BOTH work for "single tool expressions" flowDirGrd = areaIdFolderPath + "\\flowdir" flowDirTmp.save(flowDirGrd)
#Process: FlowAcc flowAccTmp = arcpy.sa.FlowAccumulation(flowDirGrd, "", "INTEGER"); showGpMessage() flowAccGrd = areaIdFolderPath + "\\flowacc" flowAccTmp.save(flowAccGrd) #Process: Create a streamlink acreThreshold = 1 acreThresholdInPixels = int(43560 * acreThreshold / cellSize ** 2) flowAccGrd = arcpy.Raster(flowAccGrd) streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccTmp > acreThresholdInPixels, 1), flowDirGrd) streamLinkGrd = areaIdFolderPath + "\\strmlnk" streamLinkTmp.save(streamLinkGrd)
#Process: FlowAcc flowAccTmp = arcpy.sa.FlowAccumulation(flowDirGrd, "", "INTEGER"); showGpMessage() flowAccGrd = areaIdFolderPath + "\\flowacc" flowAccTmp.save(flowAccGrd) #Process: Create a streamlink acreThreshold = 1 acreThresholdInPixels = int(43560 * acreThreshold / cellSize ** 2) flowAccGrd = arcpy.Raster(flowAccGrd) streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccGrd > acreThresholdInPixels, 1), flowDirGrd) streamLinkGrd = areaIdFolderPath + "\\strmlnk" streamLinkTmp.save(streamLinkGrd)
#Process: FlowAcc flowAccTmp = arcpy.sa.FlowAccumulation(flowDirGrd, "", "INTEGER"); showGpMessage() flowAccGrd = areaIdFolderPath + "\\flowacc" flowAccTmp.save(flowAccGrd) #Process: Create a streamlink acreThreshold = 1 acreThresholdInPixels = int(43560 * acreThreshold / cellSize ** 2) flowAccGrd = arcpy.Raster(flowAccGrd) streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccTmp > acreThresholdInPixels, 1), flowDirTmp) streamLinkGrd = areaIdFolderPath + "\\strmlnk" streamLinkTmp.save(streamLinkGrd)
somaExp = "con(" + flowDirGrd + " > 0 & isnull(Focalmax(" + flowDirGrd + ", 'RECTANGLE', 3, 3, 'NODATA')), 1, setnull(" + flowDirGrd + "))"
demRingTmp = arcpy.sa.Con(flowDirTmp > 0 & arcpy.sa.IsNull(arcpy.sa.FocalStatistics(flowDirTmp, arcpy.sa.NbrRectangle(3, 3, "CELL"), "MAXIMUM", "NODATA")), 1)
# your way; gave me a raster full of 1s demRingTmp = arcpy.sa.Con(flowDirTmp > 0 & arcpy.sa.IsNull(arcpy.sa.FocalStatistics(flowDirTmp, arcpy.sa.NbrRectangle(3, 3, "CELL"), "MAXIMUM", "NODATA")), 1) # my way; gave me a solid 'ring' around the data from arcpy import sa demRingTmp = sa.Con((flowDirTemp > 0) & (sa.IsNull(sa.FocalStatistics(flowDirTemp, sa.NbrRectangle(3, 3, 'CELL'), 'MAXIMUM', 'NODATA'))), 1)