<?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 - add in line variable in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107758#M3679</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;got my self in a muddle while trying to automate a tool that works for a single point. now trying to automate for many points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;%ID% - the point number i'm using (these range from 1-70)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%max% - a number &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in the raster calculator i am making dtm values less than %max% into null values using the following&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SetNull("%dtm_1%" &amp;lt; %min%,"%dtm_1%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked for my example when i used dtm_1, however i now want to run this for dtm_1, dtm_2, dtm_3... using dtm_%ID%&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if i try SetNull("%dtm_%ID%%" &amp;lt; %min%,"%dtm_%ID%%") i get an error message&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Apr 25 13:07:51 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SetNull("%dtm_%ID%%" &amp;lt; 69.555,"%dtm_%ID%%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 000732: Input Raster: Dataset %dtm_%ID%% does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Raster Calculator).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Wed Apr 25 13:07:52 2012 (Elapsed Time: 1.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;how do i get this to work properly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks in advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Apr 2012 11:09:33 GMT</pubDate>
    <dc:creator>jamiefinney</dc:creator>
    <dc:date>2012-04-25T11:09:33Z</dc:date>
    <item>
      <title>Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107758#M3679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;got my self in a muddle while trying to automate a tool that works for a single point. now trying to automate for many points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;%ID% - the point number i'm using (these range from 1-70)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%max% - a number &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in the raster calculator i am making dtm values less than %max% into null values using the following&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SetNull("%dtm_1%" &amp;lt; %min%,"%dtm_1%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked for my example when i used dtm_1, however i now want to run this for dtm_1, dtm_2, dtm_3... using dtm_%ID%&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if i try SetNull("%dtm_%ID%%" &amp;lt; %min%,"%dtm_%ID%%") i get an error message&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Apr 25 13:07:51 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SetNull("%dtm_%ID%%" &amp;lt; 69.555,"%dtm_%ID%%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 000732: Input Raster: Dataset %dtm_%ID%% does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Raster Calculator).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Wed Apr 25 13:07:52 2012 (Elapsed Time: 1.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;how do i get this to work properly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks in advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2012 11:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107758#M3679</guid>
      <dc:creator>jamiefinney</dc:creator>
      <dc:date>2012-04-25T11:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107759#M3680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jamie,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am getting the same error when trying to do a similar calculation involving in line variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Similar to you, when only using one input raster, everything is fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Only when trying to run with multiple inputs do I get the error (I am using a for loop).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My first thought was around the placement of the %, e.g. having double %% in the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried moving the variable to the middle of the name, but with no luck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Con(IsNull("%Rand_Pt%n%_flt%"),0,("%Rand_Pt%n%_flt%"*5))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 000732: Input Raster: Dataset %Rand_Pt%n%_flt% does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Raster Calculator).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have, or anyone else has, a solution, I would much appreciate a response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 12:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107759#M3680</guid>
      <dc:creator>SimonMitchell1</dc:creator>
      <dc:date>2013-09-10T12:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107760#M3681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't think you can have an in-line substitution within an in-line substitution.&amp;nbsp; So for example if you had:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;%name% = "fred"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%id% = "33"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then a valid output name would be %name%_%id% which would create fred_33&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid scenario would be %name%id%% to correct this do %name%%id%&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 14:05:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107760#M3681</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-09-10T14:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107761#M3682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;got my self in a muddle while trying to automate a tool that works for a single point. now trying to automate for many points.&lt;BR /&gt;&lt;BR /&gt;%ID% - the point number i'm using (these range from 1-70)&lt;BR /&gt;%max% - a number &lt;BR /&gt;&lt;BR /&gt;in the raster calculator i am making dtm values less than %max% into null values using the following&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SetNull("%dtm_1%" &amp;lt; %min%,"%dtm_1%")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;This worked for my example when i used dtm_1, however i now want to run this for dtm_1, dtm_2, dtm_3... using dtm_%ID%&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if i try SetNull("%dtm_%ID%%" &amp;lt; %min%,"%dtm_%ID%%")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; i get an error message&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Start Time: Wed Apr 25 13:07:51 2012
SetNull("%dtm_%ID%%" &amp;lt; 69.555,"%dtm_%ID%%")
ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 000732: Input Raster: Dataset %dtm_%ID%% does not exist or is not supported
Failed to execute (Raster Calculator).
Failed at Wed Apr 25 13:07:52 2012 (Elapsed Time: 1.00 seconds)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;how do i get this to work properly?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The other posters are right, you cannot "nest" these things. The easiest approach I can think of using is to use the Calculate Value tool with this expression; set the output to be a raster calculator expression, and connect it to the Raster Calculator tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
'SetNull("{0}_{1} &amp;lt; 69.555, "{0}_{1}")'.format("%dtm_%",%ID%)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm assuming you have model elements named "dtm_" and "ID" that will be used in the above expression at runtime, creating a string like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# %dtm_% = "raster"
# %ID% = 1
SetNull("raster1" &amp;lt; 69.555, "raster1")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't forget if all these rasters are in a folder, you can use Iterate Rasters to generate the values of "raster", then you could use a simpler expression like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
'SetNull("{0}" &amp;lt; 69.555, "{0}")'.format(r"%raster%")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(the 'r' prefix is required because Iterate Rasters generates pathnames with backslashes that must not be misinterpreted as escape codes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107761#M3682</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T06:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107762#M3683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Duncan and Curt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your responses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Although I am not sure how to apply it to my situation (I am not an expert).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I failed to mention in my post is that the input raster for the Raster Calculator is an output from another function within my for-loop iteration.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My process is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FOR (n=1 to 20)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Generate a random point (Output: Rand_Pt_%n%)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Convert random point to a raster (Output: Rand_Pt_Rast_%n%)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Use (2) as input into the raster calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, I would like to keep the intermediate steps, and why I am stuck with the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I can work around it by not giving the output from (2) the variable in the name (unfortunately, this will mean overwriting).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for any solutions that you can give me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 08:18:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107762#M3683</guid>
      <dc:creator>SimonMitchell1</dc:creator>
      <dc:date>2013-09-11T08:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator - add in line variable</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107763#M3684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried renaming the variable Rand_pt_Rast_%n% (which it is named by default when you set it up) to a legal name without the % signs? (The variable's &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;value&lt;/SPAN&gt;&lt;SPAN&gt; will be unchanged when you edit its name.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right click the variable, Rename, edit to: &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Rand_pt_rast_n.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After you validate the model (click the check mark in ModelBuilder), you should be able pick "Rand_pt_rast_n" from the list in the Raster Calculator tool dialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Sep 2013 04:40:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/raster-calculator-add-in-line-variable/m-p/107763#M3684</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-09-12T04:40:29Z</dc:date>
    </item>
  </channel>
</rss>

