def Reclass(yield) : if (yield <=140) : return "Low" elif (yield > 140 and yield <= 180) : return "Average" elif (yield > 180) :
def Reclass(x): if (x <=140): return "Low" elif (x > 140 and x <= 180): return "Average" elif (x > 180): return "High"
The expression for the Calculate Field tool should simply be (if "cat" is your field name). CAT is also then entered in the Field argument to Calculate Field.
Ted is correct that you'd want to account for non-covered fields. Seems to me it would be safer to create a new field and calculate to that in case something goes wrong.
Reclass<SPAN class="punctuation token">(</SPAN>!CAT!<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
</CODE></PRE><P>or perhaps </P><PRE class="lia-code-sample line-numbers language-none"><CODE>cat <SPAN class="operator token">=</SPAN> Reclass<SPAN class="punctuation token">(</SPAN>int<SPAN class="punctuation token">(</SPAN>!cat!<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># --- If you need to use the cat value and overwrite the string number with text</SPAN> <SPAN class="comment token"># --- Then you would also have to account for possible non numbers text in the Reclass def?</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
Your expression block should be:cat = Reclass(!yield!) Otherwise you'd be trying to read an integer from a string field.
cat = Reclass(!yield!)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.