<?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: nesting an arithmetic function within the reclass function! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451941#M35410</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It isn't called "code wrap" but &lt;STRONG&gt;Insert &amp;gt; Syntax Highlighting&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Jan 2015 18:00:12 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-01-16T18:00:12Z</dc:date>
    <item>
      <title>nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451937#M35406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have used the reclass function several times, but what I would like to know is how to add a line after the "return" that prints the value of field A + 90 instead of just "1" into the cell. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Parser:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Reclass(!WELL_YIELD!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def Reclass(WellYield):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (WellYield &amp;gt;= 0 and WellYield &amp;lt;= 10):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1 &lt;/SPAN&gt;&lt;STRONG&gt;Instead of "1" a Calculation of (Field A +90 or Field B -180) as an example.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 10 and WellYield &amp;lt;= 20):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 20 and WellYield &amp;lt;= 30):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 30):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is much appreciated! i'm hoping it's something simple and i just don't know!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Sep 2013 19:38:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451937#M35406</guid>
      <dc:creator>DanielAmrine</dc:creator>
      <dc:date>2013-09-16T19:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451938#M35407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Firstly, read this: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then do something like this:&lt;/SPAN&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;Reclass(!WELL_YIELD!,!Field_A!)&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 Reclass(WellYield, Field_A):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (WellYield &amp;gt;= 0 and WellYield &amp;lt;= 10):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Field_A +90
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 10 and WellYield &amp;lt;= 20):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 20 and WellYield &amp;lt;= 30):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 3
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (WellYield &amp;gt; 30):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 4
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:10:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451938#M35407</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T20:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451939#M35408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is great i will test it ASAP, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your response!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 12:24:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451939#M35408</guid>
      <dc:creator>DanielAmrine</dc:creator>
      <dc:date>2013-12-04T12:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451940#M35409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately using return !Field A! does not return the value from Field A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this as well and it didn't work. Keeps telling me there is a syntax error at line 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression&lt;/P&gt;&lt;P&gt;DirectionCalc( !TestNeg!, !Angle! )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;def DirectionCalc(TestNeg,Angle):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (TestNeg == 1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return float(!Angle!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg &amp;gt;1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This did work&lt;/P&gt;&lt;P style="font-size: 13.63636302948px;"&gt;def DirectionCalc(TestNeg,Angle):&lt;/P&gt;&lt;P style="font-size: 13.63636302948px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (TestNeg == 1):&lt;/P&gt;&lt;P style="font-size: 13.63636302948px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Angle&lt;/P&gt;&lt;P style="font-size: 13.63636302948px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg &amp;gt;1):&lt;/P&gt;&lt;P style="font-size: 13.63636302948px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im using chrome and i selected advanced editor but there is no option for "code wrap"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you return the value from a different field? There is no "#" button to click in this new geonet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 16:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451940#M35409</guid>
      <dc:creator>DanielAmrine</dc:creator>
      <dc:date>2015-01-16T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451941#M35410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It isn't called "code wrap" but &lt;STRONG&gt;Insert &amp;gt; Syntax Highlighting&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 18:00:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451941#M35410</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-01-16T18:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451942#M35411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are getting the syntax error on line 3 because there is no variable !Angle! in the Python function you defined.&amp;nbsp; This also explains why the second block of code doesn't give you an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you saying the second code block above, the one that works, doesn't return the correct result?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 18:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451942#M35411</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-01-16T18:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: nesting an arithmetic function within the reclass function!</title>
      <link>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451943#M35412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the second code block did work in terms of puling in the value from the Angle field and returning into the Field I am calculating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So angle + 1 would add the value from the angle field +1 into the target field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the final code I came up with to convert the angle from a previous calculation into quadrant bearings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def DirectionCalc(TestNeg,Angle):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (TestNeg == 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 90-Angle
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg == 2):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (Angle*-1)+90
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg == 3):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 270 - Angle
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg == 4):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (Angle*-1)+270
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg == 5):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (TestNeg == 6):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 90&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lower Box:&lt;/P&gt;&lt;P&gt;DirectionCalc( !TestNeg!, !Angle! )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started with a polyline layer added 4 fields... start(X,Y) and end(X,Y). Then I calculated a DeltaX and DeltaY, And used these to calculate the angle of the line from the start point. I then created TestNEG to classify which quadrant each angle fell in based on which Delta was negative...so&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def TestNegative(DeltaX,DeltaY):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (float(DeltaX) &amp;gt; 0 and float(DeltaY) &amp;gt; 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (float(DeltaX) &amp;lt; 0 and float(DeltaY) &amp;gt; 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 4
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (float(DeltaX) &amp;gt; 0 and float(DeltaY) &amp;lt; 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (float(DeltaX) &amp;lt; 0 and float(DeltaY) &amp;lt; 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 3
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (float(DeltaX) == 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif (float(DeltaY) == 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 6&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lower Box:&lt;/P&gt;&lt;P&gt;TestNegative(!DeltaX! , !DeltaY!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then apply the first box of code based on this calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could probably now combine the two codes by replacing the classification numbers with the Angle field and the calculations from the first block and that would save having to classify the values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your initial response helped a lot Joshua and i feel like a made some major headway in using python today!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nesting-an-arithmetic-function-within-the-reclass/m-p/451943#M35412</guid>
      <dc:creator>DanielAmrine</dc:creator>
      <dc:date>2021-12-11T20:10:30Z</dc:date>
    </item>
  </channel>
</rss>

