I'm very new to using python and figure I'm missing something obvious in the following script. I keep getting a "syntax error" message no matter how much I fiddle around with the first few lines. I think it has something to do with calling the spatial analyst module into python while checking out the spatial analyst extension. Any help would be greatly appreciated!
#Script takes an input DEM raster and delineates watershed boundaries based on
# flow direction and accumulation
# Import arcpy module
import arcpy
from arcpy.sa import *
arcpy.env.overwriteOutput = True
# Check out the Spatial Analyst extension
arcpy.CheckOutExtension("Spatial")
#Specify the input raster
inDEM = arcpy.GetParameterAsText(0)
#Specify the input coordinate system
spatialReference = arcpy.GetParameterAsText(1)
#Specify the minimum number of cells that are assumed to represent a stream
# (cell threshold)
inMin = arcpy.GetParameterAsText(2)
Try:
# Process: Project Raster
arcpy.ProjectRaster_management(inDEM, projectDEM, spatialReference)
# Process: Fill
fillDEM = Fill(projectDEM)
# Process: Flow Direction
flowDir = FlowDirection(fillDEM, "NORMAL")
# Process: Flow Accumulation
flowAccum = FlowAccumulation(flowDir)
# Process: Raster Calculator
outRaster = RasterCalculator((flowAccum > inMin))
# Process: Raster to Polyline
arcpy.RasterToPolyline_conversion(outRaster, polyLines, "ZERO", "0", "SIMPLIFY", "VALUE")
# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(polyLines, lineVertices, "END")
# Process: Watershed
outWatershed = Watershed(flowDir, lineVertices)
# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(outWatershed, watershedPolygons, "SIMPLIFY", "VALUE")
# Check in the Spatial Analyst extension
arcpy.CheckInExtension("Spatial")
#error handling
except:
arcpy.AddError("File failed to write successfully")
arcpy.AddMessage(arcpy.GetMessages())
#Script takes an input DEM raster and delineates watershed boundaries based on
# flow direction and accumulation
# Import arcpy module
import arcpy
from arcpy.sa import *
arcpy.env.overwriteOutput = True
# Check out the Spatial Analyst extension
arcpy.CheckOutExtension("Spatial")
#Specify the input raster
inDEM = arcpy.GetParameterAsText(0)
#Specify the input coordinate system
spatialReference = arcpy.GetParameterAsText(1)
#Specify the minimum number of cells that are assumed to represent a stream
# (cell threshold)
inMin = arcpy.GetParameterAsText(2)
Try:
# Process: Project Raster
arcpy.ProjectRaster_management(inDEM, projectDEM, spatialReference)
# Process: Fill
fillDEM = Fill(projectDEM)
# Process: Flow Direction
flowDir = FlowDirection(fillDEM, "NORMAL")
# Process: Flow Accumulation
flowAccum = FlowAccumulation(flowDir)
# Process: Raster Calculator
outRaster = RasterCalculator((flowAccum > inMin))
# Process: Raster to Polyline
arcpy.RasterToPolyline_conversion(outRaster, polyLines, "ZERO", "0", "SIMPLIFY", "VALUE")
# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(polyLines, lineVertices, "END")
# Process: Watershed
outWatershed = Watershed(flowDir, lineVertices)
# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(outWatershed, watershedPolygons, "SIMPLIFY", "VALUE")
# Check in the Spatial Analyst extension
arcpy.CheckInExtension("Spatial")
#error handling
except:
arcpy.AddError("File failed to write successfully")
arcpy.AddMessage(arcpy.GetMessages())