<?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: Different input values for raster calculator in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17392#M621</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, it's been a while since I've used ModelBuilder. The correct syntax for the expression is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;rasterVal("%Name%")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code block can remain the same, as the variable in the function definition can be anything you choose. This should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Sep 2012 21:40:57 GMT</pubDate>
    <dc:creator>JamieKass</dc:creator>
    <dc:date>2012-09-19T21:40:57Z</dc:date>
    <item>
      <title>Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17388#M617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am building a sub-model that needs to take a raster from a dataset and multiply it by a value that I input into the model as a parameter.&amp;nbsp; This is easy to do with a single raster, but I want to iterate through multiple rasters in a dataset, and for each individual raster I need to multiply it by a different value, e.g. Raster 1 * 2.5, Raster 2 * 4.7, etc...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The values need to be parameters that I can input each time I run the model.&amp;nbsp; The only thing I have come up with so far is to make the value a parameter, but the model will use that value for every raster in the dataset (see image).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]17788[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I write a python script that prompts each value before the model runs?&amp;nbsp; Or is this doable through model builder?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 20:59:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17388#M617</guid>
      <dc:creator>RobinCheskin</dc:creator>
      <dc:date>2012-09-18T20:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17389#M618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Add and link in the CalculateValue tool into your chain between BinRaster and RasterCalculator, and paste this code inside. The Data Type should be "Double".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rasterVal(BinRaster)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def rasterVal(BinRaster):
 if BinRaster == 'rastername1':
&amp;nbsp; return val1
 elif BinRaster == 'rastername2':
&amp;nbsp; return val2&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;.... and so on. The 'val1', etc variables should be entered as numbers, not strings. This code assumes that the "BinRaster" product is a string name. If not, use "arcpy.Describe(BinRaster).name", which will give you the name of the raster. You'll need to hardcode in the multipliers and raster names each time you want to change them, but this is an easy solution.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:42:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17389#M618</guid>
      <dc:creator>JamieKass</dc:creator>
      <dc:date>2021-12-10T20:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17390#M619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the advice Kass.&amp;nbsp; While this will certainly work, I would prefer not to hardcode the raster names and/or raster multipliers in the python code block window every time I run the model.&amp;nbsp; Can I enter them into something easier to use?&amp;nbsp; This needs to be usable by a wide variety of audiences (its a tool for predicting crime).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you think of a more elegant solution?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 19:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17390#M619</guid>
      <dc:creator>RobinCheskin</dc:creator>
      <dc:date>2012-09-19T19:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17391#M620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I tried this in the Code Block&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def rasterVal (BinRaster):
&amp;nbsp; if BinRaster == 'Bin_Rec_VMC_JAS_10':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1.866
&amp;nbsp; elif BinRaster == 'Bin_Rec_CADSHJAS10':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1.634
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Keep getting the same error that BinRaster is not defined. I then tried arcpy.Describe(BinRaster).name in the second line replacing BinRaster, but I get the same error...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:42:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17391#M620</guid>
      <dc:creator>RobinCheskin</dc:creator>
      <dc:date>2021-12-10T20:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17392#M621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, it's been a while since I've used ModelBuilder. The correct syntax for the expression is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;rasterVal("%Name%")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code block can remain the same, as the variable in the function definition can be anything you choose. This should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 21:40:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17392#M621</guid>
      <dc:creator>JamieKass</dc:creator>
      <dc:date>2012-09-19T21:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Different input values for raster calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17393#M622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the assistance Kass, it worked! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 14:08:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/different-input-values-for-raster-calculator/m-p/17393#M622</guid>
      <dc:creator>RobinCheskin</dc:creator>
      <dc:date>2012-09-20T14:08:21Z</dc:date>
    </item>
  </channel>
</rss>

