<?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 Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024955#M37102</link>
    <description>&lt;P&gt;I am using ArcGIS Pro 2.7.&lt;/P&gt;&lt;P&gt;I have a column of Easting values which each correspond to the bottom left corner of an OS UK grid square. I want to centre each value to be in the middle of whatever 1km grid square it intersects. The easting values are an integer field, each with a 6 digit number expressing how far the cell is from the origin of the OS UK grid.&lt;/P&gt;&lt;P&gt;To create my centred 1km square field, I want to take the first 3 digits of each easting value and replace the last 3 digits with '500'. So for example, 217890 would become 217500. I had thought to use !easting![0:3] in this part of the expression in Field Calculator, but it turns out that integer fields are not subscriptable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The somewhat laborious workaround I am using is to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Copy the easting values into a new text field as a string&lt;/P&gt;&lt;P&gt;2. Create a second new text field and populate that with the values from the new easting text field, replacing the last three characters with '500'.&lt;/P&gt;&lt;P&gt;3. Populate the centred easting, integer field with the values from the second text field.&lt;/P&gt;&lt;P&gt;There must be a way to do this in one go though - either to select digits from an integer field in Field Calculator, or replace specific digits from an integer field with another set of digits in Field Calculator? I haven't been able to find any examples of this, though.&lt;/P&gt;&lt;P&gt;Any insight much appreciated. Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2021 17:27:14 GMT</pubDate>
    <dc:creator>YusefSamari</dc:creator>
    <dc:date>2021-02-09T17:27:14Z</dc:date>
    <item>
      <title>Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024955#M37102</link>
      <description>&lt;P&gt;I am using ArcGIS Pro 2.7.&lt;/P&gt;&lt;P&gt;I have a column of Easting values which each correspond to the bottom left corner of an OS UK grid square. I want to centre each value to be in the middle of whatever 1km grid square it intersects. The easting values are an integer field, each with a 6 digit number expressing how far the cell is from the origin of the OS UK grid.&lt;/P&gt;&lt;P&gt;To create my centred 1km square field, I want to take the first 3 digits of each easting value and replace the last 3 digits with '500'. So for example, 217890 would become 217500. I had thought to use !easting![0:3] in this part of the expression in Field Calculator, but it turns out that integer fields are not subscriptable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The somewhat laborious workaround I am using is to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Copy the easting values into a new text field as a string&lt;/P&gt;&lt;P&gt;2. Create a second new text field and populate that with the values from the new easting text field, replacing the last three characters with '500'.&lt;/P&gt;&lt;P&gt;3. Populate the centred easting, integer field with the values from the second text field.&lt;/P&gt;&lt;P&gt;There must be a way to do this in one go though - either to select digits from an integer field in Field Calculator, or replace specific digits from an integer field with another set of digits in Field Calculator? I haven't been able to find any examples of this, though.&lt;/P&gt;&lt;P&gt;Any insight much appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 17:27:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024955#M37102</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2021-02-09T17:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024960#M37103</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a python expression you can easily 'switch' between string and int data types (called type conversion I believe).&lt;/P&gt;&lt;P&gt;this is done using the str() and int() functions.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#returns a string
str(!easting!)[0:3] + '500'
#turns that string back to a number
int(str(!easting!)[0:3] + '500')&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Feb 2021 17:34:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024960#M37103</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-09T17:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024984#M37109</link>
      <description>&lt;P&gt;If you want to keep it as an integer data type, you can use &lt;EM&gt;integer division&lt;/EM&gt; with some basic arithmetic.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;values = [217890, 218330, 216540]

for v in values:
    print(f'{v} -&amp;gt; {v // 1000 * 1000 + 500}')&lt;/LI-CODE&gt;&lt;P&gt;Returns:&lt;/P&gt;&lt;P&gt;217890 -&amp;gt; 217500&lt;BR /&gt;218330 -&amp;gt; 218500&lt;BR /&gt;216540 -&amp;gt; 216500&lt;/P&gt;&lt;P&gt;Integer division, the &lt;STRONG&gt;//&lt;/STRONG&gt; operator, drops the remainder of the division. It's like the Abbott to &lt;EM&gt;modulo&lt;/EM&gt;'s Costello.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 18:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024984#M37109</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-02-09T18:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024985#M37110</link>
      <description>&lt;P&gt;never seen // before, nice!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 18:48:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1024985#M37110</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-09T18:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025068#M37120</link>
      <description>&lt;P&gt;It is akin to "floor_divide"&lt;/P&gt;&lt;LI-CODE lang="python"&gt;values = np.array([217890, 218330, 216540])

np.floor_divide(values, 1000) * 1000 + 500

array([217500, 218500, 216500], dtype=int32)&lt;/LI-CODE&gt;&lt;P&gt;Got to have a numpy example&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:04:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025068#M37120</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-09T22:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025257#M37138</link>
      <description>&lt;P&gt;Thanks! Unfortunately I'm still getting the same error message. Seems it still doesn't like the attempt to subscript an integer field, even with the string function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YusefSamari_0-1612949044664.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5724iF87879CBA26288CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YusefSamari_0-1612949044664.png" alt="YusefSamari_0-1612949044664.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I don't know why Field Type is showing as 'TEXT' there - the 'test' field I created is definitely an integer field.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 09:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025257#M37138</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2021-02-10T09:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025258#M37139</link>
      <description>&lt;P&gt;Lovely and very simple! This works fine, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 09:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025258#M37139</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2021-02-10T09:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025299#M37147</link>
      <description>&lt;P&gt;You have the brackets/parentheses messed up - must be str(!Eastings!)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:00:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025299#M37147</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-10T13:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve a digit or string of digits from an integer field with ArcGIS Pro field calculator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025328#M37150</link>
      <description>&lt;P&gt;Woops! Thanks, that's working now.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 14:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retrieve-a-digit-or-string-of-digits-from-an/m-p/1025328#M37150</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2021-02-10T14:10:22Z</dc:date>
    </item>
  </channel>
</rss>

