<?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 Raster Calculator Function Does not Takes Predefined Variable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134298#M10530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have written a python script&amp;nbsp;that finds the mean of all pixel values in a raster. Once I get the mean (suppose 0.3 in this case), I can use raster calculator and assign pixel value of 1 to each pixel higher than the mean and 0 to everything else. The equation is as follows -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Float(Con("Raster1"&amp;lt;0.3, 0, 1))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there are 30 raster&amp;nbsp;files, thus, I want to avoid manually using the Raster Calculator. I have&amp;nbsp;added the following codes to the script-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raster_mean = got from previous script [0.3 in this case]&lt;/P&gt;&lt;P&gt;arcpy.gp.RasterCalculator_sa('&lt;SPAN&gt;Float(Con("Raster1"&amp;lt;Raster_mean, 0, 1))' ,&amp;nbsp; "E:/ArcGIS Python/raster10")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the following errors-&lt;/P&gt;&lt;P&gt;NameError: name '&lt;SPAN&gt;Raster_mean&lt;/SPAN&gt;' is not defined.&amp;nbsp; Failed to execute (RasterCalculator).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems like it does not take any predefined variable but only raw values. Is there any other option to conduct the task?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jun 2018 17:07:15 GMT</pubDate>
    <dc:creator>Md_Abdullah_All_Sourav</dc:creator>
    <dc:date>2018-06-07T17:07:15Z</dc:date>
    <item>
      <title>Raster Calculator Function Does not Takes Predefined Variable</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134298#M10530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have written a python script&amp;nbsp;that finds the mean of all pixel values in a raster. Once I get the mean (suppose 0.3 in this case), I can use raster calculator and assign pixel value of 1 to each pixel higher than the mean and 0 to everything else. The equation is as follows -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Float(Con("Raster1"&amp;lt;0.3, 0, 1))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there are 30 raster&amp;nbsp;files, thus, I want to avoid manually using the Raster Calculator. I have&amp;nbsp;added the following codes to the script-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raster_mean = got from previous script [0.3 in this case]&lt;/P&gt;&lt;P&gt;arcpy.gp.RasterCalculator_sa('&lt;SPAN&gt;Float(Con("Raster1"&amp;lt;Raster_mean, 0, 1))' ,&amp;nbsp; "E:/ArcGIS Python/raster10")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the following errors-&lt;/P&gt;&lt;P&gt;NameError: name '&lt;SPAN&gt;Raster_mean&lt;/SPAN&gt;' is not defined.&amp;nbsp; Failed to execute (RasterCalculator).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems like it does not take any predefined variable but only raw values. Is there any other option to conduct the task?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2018 17:07:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134298#M10530</guid>
      <dc:creator>Md_Abdullah_All_Sourav</dc:creator>
      <dc:date>2018-06-07T17:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Function Does not Takes Predefined Variable</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134299#M10531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this line&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;Raster_mean = got from previous script [0.3 in this case]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;throw a...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;msg = "mean from script {}... type {}".format(Raster_mean, type(Raster_mean))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;arcpy.AddMessage(msg)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;print(msg) # if using standalone python&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;What do you get? and if the type isn't a number type (int, float etc) then something is wrong with the passing of the parameter to the script&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2018 23:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134299#M10531</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-06-07T23:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Function Does not Takes Predefined Variable</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134300#M10532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just used Con and it worked as a charm. Here are the codes-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inRaster = Raster(NDVI_file)&lt;BR /&gt;outCon = Con(inRaster &amp;lt; mean, 0,1)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2018 17:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134300#M10532</guid>
      <dc:creator>Md_Abdullah_All_Sourav</dc:creator>
      <dc:date>2018-06-09T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Function Does not Takes Predefined Variable</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134301#M10533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh good... so Raster_mean had nothing to do with it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2018 18:18:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134301#M10533</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-06-09T18:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Function Does not Takes Predefined Variable</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134302#M10534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here, I assumed&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;mean =&amp;nbsp;&lt;SPAN&gt;Raster_mean. The code is pretty different (variables), I just tried to simplify that.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2018 18:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-function-does-not-takes/m-p/134302#M10534</guid>
      <dc:creator>Md_Abdullah_All_Sourav</dc:creator>
      <dc:date>2018-06-12T18:04:07Z</dc:date>
    </item>
  </channel>
</rss>

