<?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 Model Builder - Select, Select by Attribute, Calculate Field, and Coded Domains in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-select-select-by-attribute-calculate/m-p/351808#M12214</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Two issues:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) I'm trying to build a model that will take the table of a feature class and replace certain values in the same feature class. Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have [field] with values (coded domains) of -1, 1, 2, 3, 4, X. Every time the coded domain is -1, I want to replace it with X.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are ~15 fields that I want to do this with. Currently I am using Select Layer By Attribute, however this seems to mean that I have to have the layer in the .mxd to use the tool, and I would ideally like to run it from catalog. If I switch to using Select then I get a new feature class of my selection which will not work because in the end I need the whole table (or maybe there is a way it will work that I'm just not aware of yet).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there another tool to use, or a code block that I can tweak (there has to be...) in the Calculate field tool to select the records I want to change? I'm pretty decent with programming logic, but syntax is another issue entirely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I have a coded domain value of 001, stored as text. I want to create a variable paramater for the model where the input will be exactly 001 and this will be used to calculate the field value. The problem is that every way that I do this the field updates to 1... unless I enclose 001 in double quotes. I was hoping to use the variable for other calculations where the quotes are not neccessary, and it would be best if I didn't need to rely on the user to read instructions about putting this parameter in double quotes (plenty of headaches could be avoided). Any way to do this??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2014 11:21:57 GMT</pubDate>
    <dc:creator>KathrynTucker</dc:creator>
    <dc:date>2014-06-10T11:21:57Z</dc:date>
    <item>
      <title>Model Builder - Select, Select by Attribute, Calculate Field, and Coded Domains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-select-select-by-attribute-calculate/m-p/351808#M12214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Two issues:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) I'm trying to build a model that will take the table of a feature class and replace certain values in the same feature class. Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have [field] with values (coded domains) of -1, 1, 2, 3, 4, X. Every time the coded domain is -1, I want to replace it with X.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are ~15 fields that I want to do this with. Currently I am using Select Layer By Attribute, however this seems to mean that I have to have the layer in the .mxd to use the tool, and I would ideally like to run it from catalog. If I switch to using Select then I get a new feature class of my selection which will not work because in the end I need the whole table (or maybe there is a way it will work that I'm just not aware of yet).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there another tool to use, or a code block that I can tweak (there has to be...) in the Calculate field tool to select the records I want to change? I'm pretty decent with programming logic, but syntax is another issue entirely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I have a coded domain value of 001, stored as text. I want to create a variable paramater for the model where the input will be exactly 001 and this will be used to calculate the field value. The problem is that every way that I do this the field updates to 1... unless I enclose 001 in double quotes. I was hoping to use the variable for other calculations where the quotes are not neccessary, and it would be best if I didn't need to rely on the user to read instructions about putting this parameter in double quotes (plenty of headaches could be avoided). Any way to do this??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 11:21:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-select-select-by-attribute-calculate/m-p/351808#M12214</guid>
      <dc:creator>KathrynTucker</dc:creator>
      <dc:date>2014-06-10T11:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Select, Select by Attribute, Calculate Field, and Coded Domains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-select-select-by-attribute-calculate/m-p/351809#M12215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could use CalculateField_management&amp;nbsp; for the first problem&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;using a code block that tests the existing value &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and if it is -1, change it to X&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and otherwise leave it alone.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With 15 fields to test, an update cursor with a similar test may be advisable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for the second problem, you can accept the input as a string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as (for example: 1, 01 or 001) and use zfill(3) to pad out the entered string with zeros.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, whenever you want to use it as a number just convert it to an integer &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int("001") returns 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Integers don't have leading zeros, so they get stripped off&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and however the user entered the string (for example, again: 1, 01 or 001) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the string gets padded to "001"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 17:32:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-select-select-by-attribute-calculate/m-p/351809#M12215</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2014-06-10T17:32:06Z</dc:date>
    </item>
  </channel>
</rss>

