<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Syntax error using ArcPy Spatial Analyst module in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308732#M24031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;# Check in the Spatial Analyst extension&lt;/P&gt;&lt;P&gt;arcpy.CheckInExtension("Spatial")&lt;/P&gt;&lt;P&gt;these 2 lines are incorrectly dedented, they should be within the try block ... also 'try' is lower case&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And do format the code using the advanced editor's syntax highlighting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 14 Dec 2014 22:34:28 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2014-12-14T22:34:28Z</dc:date>
    <item>
      <title>Syntax error using ArcPy Spatial Analyst module in Python</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308729#M24028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm very new to using python and figure I'm missing something obvious in the following script.&amp;nbsp; I keep getting a "syntax error" message no matter how much I fiddle around with the first few lines.&amp;nbsp; 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!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Script takes an input DEM raster and delineates watershed boundaries based on&lt;/P&gt;&lt;P&gt;# flow direction and accumulation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Check out the Spatial Analyst extension&lt;/P&gt;&lt;P&gt;arcpy.CheckOutExtension("Spatial")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Specify the input raster&lt;/P&gt;&lt;P&gt;inDEM = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Specify the input coordinate system&lt;/P&gt;&lt;P&gt;spatialReference = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Specify the minimum number of cells that are assumed to represent a stream&lt;/P&gt;&lt;P&gt;# (cell threshold)&lt;/P&gt;&lt;P&gt;inMin = arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Project Raster&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ProjectRaster_management(inDEM, projectDEM, spatialReference)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Fill&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fillDEM = Fill(projectDEM)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Flow Direction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowDir = FlowDirection(fillDEM, "NORMAL")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Flow Accumulation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowAccum = FlowAccumulation(flowDir)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Raster Calculator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = RasterCalculator((flowAccum &amp;gt; inMin))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Raster to Polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolyline_conversion(outRaster, polyLines, "ZERO", "0", "SIMPLIFY", "VALUE")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Feature Vertices To Points&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureVerticesToPoints_management(polyLines, lineVertices, "END")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Watershed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outWatershed = Watershed(flowDir, lineVertices)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Raster to Polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outWatershed, watershedPolygons, "SIMPLIFY", "VALUE")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Check in the Spatial Analyst extension&lt;/P&gt;&lt;P&gt;arcpy.CheckInExtension("Spatial")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#error handling&lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Script failed to write successfully")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages())&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 21:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308729#M24028</guid>
      <dc:creator>JessicaSorrell</dc:creator>
      <dc:date>2014-12-14T21:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error using ArcPy Spatial Analyst module in Python</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308730#M24029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Posting code with syntax highlighting and numbers is useful, as well as specific error messages.&amp;nbsp; For syntax highlighting, click the 'Use advanced editor' link in the upper right corner of the question/reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know whether the Spatial Analyst extension is being correctly checked out?&amp;nbsp; What is the return value of checking out the license?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 21:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308730#M24029</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-12-14T21:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error using ArcPy Spatial Analyst module in Python</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308731#M24030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your &lt;CODE&gt;Try:&lt;/CODE&gt; statement is capitalised, it should be lower case &lt;CODE&gt;try:&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 22:33:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308731#M24030</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2014-12-14T22:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error using ArcPy Spatial Analyst module in Python</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308732#M24031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;# Check in the Spatial Analyst extension&lt;/P&gt;&lt;P&gt;arcpy.CheckInExtension("Spatial")&lt;/P&gt;&lt;P&gt;these 2 lines are incorrectly dedented, they should be within the try block ... also 'try' is lower case&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And do format the code using the advanced editor's syntax highlighting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 22:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-using-arcpy-spatial-analyst-module-in/m-p/308732#M24031</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-12-14T22:34:28Z</dc:date>
    </item>
  </channel>
</rss>

