<?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: Calculate Field, Helpers, Reclassify, If/elif in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1328020#M72977</link>
    <description>&lt;P&gt;A bit late, but maybe this will help others.&amp;nbsp; The original code needed first to have != changed to == (as mentioned above).&amp;nbsp; But once you do that, you're right, you could combine all of the statements that wanted to set the value to 4 by using a list and then checking for membership in the list.&amp;nbsp; For example, you could do something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;four_type_soils = ["Till", "Paleasol", "Clay"]
if fld == "Soil or Fill":
  a = 1
elif fld == "Alluvium":
  a = 2
elif fld == "Loess":
  a = 3
elif fld in four_type_soils:
  a = 4
else:
  a = 9 
  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 21:51:03 GMT</pubDate>
    <dc:creator>LauraTateosian_augori</dc:creator>
    <dc:date>2023-09-12T21:51:03Z</dc:date>
    <item>
      <title>Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106085#M46501</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Hello, in PRO I am trying to use Python / Code Block to use existing field !prim_lith! (text field, with geologic material descriptions, eg, clay, sand) to populate a new field !prim_lith_reclass! (short integer field) whose value 1, 2, 3,...9 depends on the geologic material in&amp;nbsp;!prim_lith!.&amp;nbsp; The Expression is valid and runs but the return values are all equal to 1 (from line 3 in the code block), see lower right of attached jpg. I've tried varied syntax etc. but nothing seems to work.&amp;nbsp; Should text be in double quotes "text", or double apostrophe 'text' ?&amp;nbsp; What is the difference between !=&amp;nbsp; and == ?&amp;nbsp; Do I have to explicitly enter an Else?&lt;/P&gt;&lt;P&gt;Any insights would be greatly appreciated. Thank you!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Oct 2021 19:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106085#M46501</guid>
      <dc:creator>GJB</dc:creator>
      <dc:date>2021-10-08T19:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106096#M46505</link>
      <description>&lt;P&gt;&lt;STRONG&gt;!=&lt;/STRONG&gt; means "not equal to"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;==&lt;/STRONG&gt; means "equal to"&lt;/P&gt;&lt;P&gt;I think you have put != instead of == ?&lt;/P&gt;&lt;P&gt;Please replace != with ==&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 19:48:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106096#M46505</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2021-10-08T19:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106101#M46506</link>
      <description>&lt;P&gt;Thank you, that makes sense. I replaced as suggest and the expression is still valid but now get a run error 000539 (attached).&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 19:54:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106101#M46506</guid>
      <dc:creator>GJB</dc:creator>
      <dc:date>2021-10-08T19:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106122#M46507</link>
      <description>&lt;P&gt;please format your code, you're also not showing the entire code block.&amp;nbsp; It makes it very tedious to try and help you&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Can't even see line 42 of your code.&lt;/P&gt;&lt;P&gt;I would add an else at the end to take into account misspellings etc. set it as something like 999,-999 or whatever.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;else:
  a = 999
return a&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 20:17:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106122#M46507</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-10-08T20:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106137#M46509</link>
      <description>&lt;P&gt;Putting the whole codeblock here would help.&lt;/P&gt;&lt;P&gt;Ensure that you have returned variable&amp;nbsp;&lt;STRONG&gt;a&lt;/STRONG&gt; with appropriate indentation.&lt;/P&gt;&lt;P&gt;Could you check with a code-block similar to the following&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JayantaPoddar_0-1633725993951.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/24893i3075201E341DBE95/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JayantaPoddar_0-1633725993951.png" alt="JayantaPoddar_0-1633725993951.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def Reclass(fld):
    if fld=='soil or fill':
        return 1
    elif fld=='alluvium':
        return 2
    else:
        return 9&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 20:48:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106137#M46509</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2021-10-08T20:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106152#M46512</link>
      <description>&lt;P&gt;Okay I apologize for that. I couldn't fit the vertical extent of the code block into Snip so I've attached the top and bottom halves.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I incorporated your ideas and the code now works!&amp;nbsp; Thank you for the insights!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 21:11:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106152#M46512</guid>
      <dc:creator>GJB</dc:creator>
      <dc:date>2021-10-08T21:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106170#M46517</link>
      <description>&lt;P&gt;Glad we could help!&lt;/P&gt;&lt;P&gt;For your future queries, here is&amp;nbsp;&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_blank"&gt;How to insert code in your post - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 22:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1106170#M46517</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2021-10-08T22:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1115056#M47639</link>
      <description>&lt;P&gt;In the code that was submitted is an elif statement needed for all values even if they are to be classified into the same category? I am seeing at least 7 values where a=4 but am wondering if all of these classes that will be reclassified could be included in the same piece of code? I am trying to do something similar so seeing if there is a more concise way of writing the code block&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 21:34:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1115056#M47639</guid>
      <dc:creator>SGuiryVR</dc:creator>
      <dc:date>2021-11-08T21:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field, Helpers, Reclassify, If/elif</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1328020#M72977</link>
      <description>&lt;P&gt;A bit late, but maybe this will help others.&amp;nbsp; The original code needed first to have != changed to == (as mentioned above).&amp;nbsp; But once you do that, you're right, you could combine all of the statements that wanted to set the value to 4 by using a list and then checking for membership in the list.&amp;nbsp; For example, you could do something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;four_type_soils = ["Till", "Paleasol", "Clay"]
if fld == "Soil or Fill":
  a = 1
elif fld == "Alluvium":
  a = 2
elif fld == "Loess":
  a = 3
elif fld in four_type_soils:
  a = 4
else:
  a = 9 
  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-helpers-reclassify-if-elif/m-p/1328020#M72977</guid>
      <dc:creator>LauraTateosian_augori</dc:creator>
      <dc:date>2023-09-12T21:51:03Z</dc:date>
    </item>
  </channel>
</rss>

