<?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 Select by Location + Field Calculator in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394925#M13417</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all.&amp;nbsp; I'm trying to improve on my automation skills but have hit a road block.&amp;nbsp; I'm trying to update features in a specific area and replace all SLOPE values of 999 with 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using model builder and can successfully run select by location to identify the drain features within the defined boundary polygon.&amp;nbsp; However, I am running into problems using Field Calculator to replace the attributes of those specific drains.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For VB I was using &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;replace([SLOPE]"999","0")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; and I receive a VBA Error code saying "Expected ')'" End of statement as I understand?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried running it through a python script I had found and tried:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!SLOPE!.replace("999","0") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is returning a syntax error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to running code and am just jumping in but this would help tremendously to other field classes where I have been stuck using Find&amp;amp;Replace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Sep 2011 12:32:42 GMT</pubDate>
    <dc:creator>NDC</dc:creator>
    <dc:date>2011-09-26T12:32:42Z</dc:date>
    <item>
      <title>Select by Location + Field Calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394925#M13417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all.&amp;nbsp; I'm trying to improve on my automation skills but have hit a road block.&amp;nbsp; I'm trying to update features in a specific area and replace all SLOPE values of 999 with 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using model builder and can successfully run select by location to identify the drain features within the defined boundary polygon.&amp;nbsp; However, I am running into problems using Field Calculator to replace the attributes of those specific drains.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For VB I was using &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;replace([SLOPE]"999","0")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; and I receive a VBA Error code saying "Expected ')'" End of statement as I understand?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried running it through a python script I had found and tried:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!SLOPE!.replace("999","0") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is returning a syntax error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to running code and am just jumping in but this would help tremendously to other field classes where I have been stuck using Find&amp;amp;Replace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 12:32:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394925#M13417</guid>
      <dc:creator>NDC</dc:creator>
      <dc:date>2011-09-26T12:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Slect by Location +Field Calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394926#M13418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Nick,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the problem here is that your values might be stored as numbers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;!SLOPE!.replace('999', '0') &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;would work perfectly well with strings. The thing is, replace is a string method and so needs an input that is such.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your easiest (though sloppiest IMO) option would be to do something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;int(str(!TNODE_!).replace('10','00'))&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;which converts your number to a string, executes the replace method, and then converts the result back into an integer (or float, or whatever you need.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something more structured that would allow more flexibility in your logic would involve using the Codeblock in the Field Calculator, where the Code Block would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def quick_check(val):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if val == 999:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; return val&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and your main expression would be&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SLOPE =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;quick_check(!SLOPE!)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In this way, you're passing the value in SLOPE to the function above, which returns 0 if it's 999, or the regular value if it's not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:05:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394926#M13418</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2021-12-11T18:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Slect by Location +Field Calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394927#M13419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What would be the VB script to select and replace the integer values?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 15:40:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394927#M13419</guid>
      <dc:creator>NDC</dc:creator>
      <dc:date>2011-09-26T15:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Slect by Location +Field Calculator</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394928#M13420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm asking because I keep getting an improper use of Null error when trying to populate the field&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 17:02:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/select-by-location-field-calculator/m-p/394928#M13420</guid>
      <dc:creator>NDC</dc:creator>
      <dc:date>2011-09-26T17:02:35Z</dc:date>
    </item>
  </channel>
</rss>

