Syntax error using ArcPy Spatial Analyst module in Python

Discussion in 'Python' started by jks5423, Dec 14, 2014.

  1. jks5423


    Dec 14, 2014
    Likes Received:
    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 import *
    arcpy.env.overwriteOutput = True

    # Check out the Spatial Analyst extension

    #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)


    # 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

    #error handling
    arcpy.AddError("File failed to write successfully")
    jks5423, Dec 14, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.