<?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: Question for a script!! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537835#M42068</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;math.pow() will not work with rasters, only with numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/power.htm"&gt;Power&lt;/A&gt; tool can take value or raster inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This used to be the pow() function in GRID and Arc 9.x map algebra. I miss that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and, Python string substitution is your friend. compare these two:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14587127817913446" data-renderedposition="216_8_1157_16" jivemacro_uid="_14587127817913446"&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;hydRad1 + '* ((' + flowAcc + ' * ' + cellSqMilesStr + ') ^ ' + hydRad + ')'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1458712788144228 jive_text_macro" data-renderedposition="258_8_1157_16" jivemacro_uid="_1458712788144228"&gt;&lt;P&gt;"{} * (({} * {}) ** {}".format(hydRad1, flowAcc, cellSqMilesStr, hydRad)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Mar 2016 05:55:08 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2016-03-23T05:55:08Z</dc:date>
    <item>
      <title>Map Algebra syntax for exponentiation (raising to a power)</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537832#M42065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I use an hydro tool developped by the Mineasota Gov. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Description: This script creates a raster whose cells measure the length of time&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in seconds, that it takes water to flow across it and then accumulates&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the time from the cell to the outlet of the watershed. water velocity&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is calculated as a function of hydraulic radius, Manning's N and slope&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using a DEM as a source, flow direction, flow accumulation and slope (percent)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; is calculated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This tool creates a lot of raster by on various imputs and formulas. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to change a formula:, this is the original: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;exp = '(' + str(hydRad1) + ' * (' + flowAcc + ' * ' + cellSqMilesStr + ')) + ' + str(hydRad2) + '' &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I would like is : hydRad1 * ((' + flowAcc + ' * ' + cellSqMilesStr + ') ^ hydRad)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 01:18:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537832#M42065</guid>
      <dc:creator>AlainSte-Marie</dc:creator>
      <dc:date>2014-02-25T01:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537833#M42066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If&amp;nbsp; I understand you correctly, you want to use power operation in your formula.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Python, the hat operator (^) means binary XOR, whereas double times (**) is used to indicate power.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ** operator is recognized by Spatial Analyst too, so your desired formula would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;exp2 = str(hydRad1) + ' * ((' + str(flowAcc) + ' * ' + atr(cellSqMilesStr) + ') ** ' + str(hydRad) + ')'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should work if your operands are scalar values or saved raster datasets, not temporary arcpy.Raster objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure your last operand is correct (is it hydRad or hydRad2 ?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If licensing of the script allows, you should be able to simply change the line in the script and run the tool again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Filip.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 20:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537833#M42066</guid>
      <dc:creator>FilipKrál</dc:creator>
      <dc:date>2014-02-25T20:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537834#M42067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I prefer using the math module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import math

# In the use of the 'math.pow' method, the value x is raised to the power of y
math.pow(x, y)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:20:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537834#M42067</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2021-12-11T23:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537835#M42068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;math.pow() will not work with rasters, only with numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/power.htm"&gt;Power&lt;/A&gt; tool can take value or raster inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This used to be the pow() function in GRID and Arc 9.x map algebra. I miss that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and, Python string substitution is your friend. compare these two:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14587127817913446" data-renderedposition="216_8_1157_16" jivemacro_uid="_14587127817913446"&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;hydRad1 + '* ((' + flowAcc + ' * ' + cellSqMilesStr + ') ^ ' + hydRad + ')'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1458712788144228 jive_text_macro" data-renderedposition="258_8_1157_16" jivemacro_uid="_1458712788144228"&gt;&lt;P&gt;"{} * (({} * {}) ** {}".format(hydRad1, flowAcc, cellSqMilesStr, hydRad)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2016 05:55:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537835#M42068</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2016-03-23T05:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537836#M42069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point, Curtis. &lt;/P&gt;&lt;P&gt;String substitution aka string formatting can make the whole code much more readable. Especially considering all the options the &lt;A href="https://docs.python.org/2/library/stdtypes.html#str.format"&gt;format method&lt;/A&gt; offers.&lt;/P&gt;&lt;P&gt;F.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 22:54:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537836#M42069</guid>
      <dc:creator>FilipKrál</dc:creator>
      <dc:date>2016-03-29T22:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537837#M42070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Filip.... some other links as well &lt;A href="https://community.esri.com/migration-blogpost/55578"&gt;Basic fancy formats ....&lt;/A&gt; cover simple and other data structures&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 23:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537837#M42070</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-29T23:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Question for a script!!</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537838#M42071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And, I should add in Python you should not use the map algebra tool. Best to do Python map algebra directly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from arcpy.sa import *
outras = Raster(hydRad1) * ((Raster(flowAcc) * float(cellSqMilesStr) ** Raster(hydRad)
# or
outras = Raster(hydRad1) * Power((Raster(flowAcc) * float(cellSqMilesStr), Raster(hydRad))
outras.save("results.tif")&lt;/PRE&gt;&lt;P&gt;&lt;A href="http://gis.stackexchange.com/questions/141956/multiprocessing-with-arcpy-and-solar-analyst-spatial-analyst" title="http://gis.stackexchange.com/questions/141956/multiprocessing-with-arcpy-and-solar-analyst-spatial-analyst" rel="nofollow noopener noreferrer" target="_blank"&gt; &lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:20:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537838#M42071</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T23:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Map Algebra syntax for exponentiation (raising to a power)</title>
      <link>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537839#M42072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alain,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am interested in the hydro tool that you referenced in your question from 2014.&amp;nbsp; Were you ever able to make it work with the changes to the equation concerning the power.&amp;nbsp; I would be interested in seeing the new code that was created for this tool as we use this tool in Minnesota.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2018 19:08:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/map-algebra-syntax-for-exponentiation-raising-to-a/m-p/537839#M42072</guid>
      <dc:creator>RickMoore1</dc:creator>
      <dc:date>2018-03-28T19:08:03Z</dc:date>
    </item>
  </channel>
</rss>

