<?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: model builder raster calculator converted to python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299477#M23182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, thanks.&amp;nbsp; Its slowly coming back to me.&amp;nbsp;&amp;nbsp; Now the new errors seam to be caused by a mix of integers, floats &amp;amp; string in my map algebra expression.&amp;nbsp; My inRaster &amp;amp; imageMin are integers while my imageMean and imageSTDEV are floats but some of these variables are coming in as stings too.&amp;nbsp; It a matter of getting the right conversions going now and I think is should work!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jun 2011 13:51:29 GMT</pubDate>
    <dc:creator>AliceDeschamps1</dc:creator>
    <dc:date>2011-06-28T13:51:29Z</dc:date>
    <item>
      <title>model builder raster calculator converted to python script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299474#M23179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I exported this from a working model builder tool and working on modifying to make it work in python.&amp;nbsp; In the end I would like to be able the automatically rename the output =&amp;gt; input + ST_DEV + enh.tif .&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am fairly new to Python so I am not there yet!&amp;nbsp; Python does not seam to recognize the map algebra from arcpy.gp.RasterCalculator_sa that was exported from Model Builder.&amp;nbsp;&amp;nbsp; Therefore I decided to convert this part to straight python map algebra but I keep on getting errors for the code under # Process: Raster Calculator (1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"RuntimeError: ERROR 000732: Input Raster: Dataset inRaster does not exist or is not supported."&amp;nbsp;&amp;nbsp; This does not make sense to me since the inRaster is recognised in the previous 3 GetRasterProperties statements since the print statements are ouputting the right values?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on how to make this work??&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# copy and past this at promt: 15May2011_HH_set_zero_8bit.tif 3 test.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import arcpy module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys, string, os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set Geoprocessing environments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "C:/Alice"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Check out any necessary licenses&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CheckOutExtension("spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inRaster = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No_STDEV = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Enhanced_8bit_SAR_Image = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Get Raster Properties (2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;imageMin=arcpy.GetRasterProperties_management(inRaster, "MINIMUM")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Image MIN value=", imageMin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Get Raster Properties (3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;imageMean=arcpy.GetRasterProperties_management(inRaster, "MEAN")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Image MEAN value=", imageMean&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Get Raster Properties&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;imageSTDEV=arcpy.GetRasterProperties_management(inRaster, "STD")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Image STDEV value=", imageSTDEV&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Raster Calculator (1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;enhImage=((Raster("inRaster") - imageMin) / ((imageMean + No_STDEV * imageSTDEV) - imageMin)) * 255&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Raster Calculator (2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outCon= Con(enhImage, enhImage, 255, "VALUE &amp;lt; 255")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Copy Raster&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyRaster_management(outCon, Output_Enhanced_8bit_SAR_Image, "", "", "", "NONE", "NONE", "8_BIT_UNSIGNED")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Jun 2011 11:50:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299474#M23179</guid>
      <dc:creator>AliceDeschamps1</dc:creator>
      <dc:date>2011-06-26T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: model builder raster calculator converted to python script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299475#M23180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Fixed the error mentioned above with the code below.&amp;nbsp; Of course, I get a new error for same line ;(&amp;nbsp;&amp;nbsp; Either the syntax or that .save?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: linear stretch with right tail trim&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;enhImage = ((Raster(inRaster) - imageMin) / ((imageMean + No_STDEV * imageSTDEV) - imageMin)) * 255&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;enhImage.save("enhImage")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2011 14:02:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299475#M23180</guid>
      <dc:creator>AliceDeschamps1</dc:creator>
      <dc:date>2011-06-27T14:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: model builder raster calculator converted to python script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299476#M23181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Take care not to quote variable names as quoting indicates it's a string, not a variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, not a big deal since there is no indentation in this script, but it makes it easier to read when you use the CODE tags (#) icon on the formatting toolbar above the message body box on your code to preserve indentation, which is significant in Python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2011 16:17:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299476#M23181</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-06-27T16:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: model builder raster calculator converted to python script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299477#M23182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, thanks.&amp;nbsp; Its slowly coming back to me.&amp;nbsp;&amp;nbsp; Now the new errors seam to be caused by a mix of integers, floats &amp;amp; string in my map algebra expression.&amp;nbsp; My inRaster &amp;amp; imageMin are integers while my imageMean and imageSTDEV are floats but some of these variables are coming in as stings too.&amp;nbsp; It a matter of getting the right conversions going now and I think is should work!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jun 2011 13:51:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-raster-calculator-converted-to/m-p/299477#M23182</guid>
      <dc:creator>AliceDeschamps1</dc:creator>
      <dc:date>2011-06-28T13:51:29Z</dc:date>
    </item>
  </channel>
</rss>

