GISHydroNXT System Documentation
#*********************************************************************************
# Author: UMD
# Date: 24-07-2018
# Modified: n/a
# Classes: FlowPaths()
# Functions: n/a
# Modules: arcpy
# Comments: n/a
#*********************************************************************************
class FlowPaths(object):
"""Implementation for GISHydroNXT_addin.tool4 (Tool)"""
def __init__(self):
self.enabled = False
self.cursor = 3
def onMouseDownMap(self, x, y, button, shift):
#*******************************************************************************************************
# add line to view -- addOutputsToMap
#*******************************************************************************************************
arcpy.env.scratchWorkspace = scratchfolder
arcpy.env.workspace = optfolder
arcpy.env.addOutputsToMap = True
point = arcpy.Point(x,y)
ptGeometry = arcpy.PointGeometry(point)
theLine = arcpy.sa.CostPath(ptGeometry, optfolder + "/dem", optfolder + "/flowdir_dem", "BEST_SINGLE")
theLine_masked = arcpy.sa.Times(theLine,optfolder + "/basingrid")
arcpy.sa.StreamToFeature(theLine_masked, optfolder + "/flowdir", "line.shp", "NO_SIMPLIFY")
searchcursor = arcpy.da.SearchCursor("line", ("OID@","SHAPE@"))
firstrow = searchcursor.next()
insertcursor = arcpy.da.InsertCursor(optfolder + "/AddasStreams.shp",("OID@","SHAPE@"))
insertcursor.insertRow(firstrow)
del firstrow,insertcursor,searchcursor
#*******************************************************************************************************
# change stream flow path symbology
#*******************************************************************************************************
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in layers:
if lyr.name == "line":
lyr.visible = False
if lyr.name == "AddasStreams":
arcpy.ApplySymbologyFromLayer_management(lyr,r"" + Directory + "/data/mdfiles/legends/streams.lyr")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
button1.enabled = False
button5_1.enabled = False