<?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 Using Calculate Field to Round Coordinates in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212564#M59827</link>
    <description>&lt;P&gt;I am using the calculated geometry to get the Lat/Long of my points on a map in DMS. It works well, but I need the seconds rounded to 2 decimal places.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaraJCourter_0-1663172387095.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51187iA6816719F722EC22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SaraJCourter_0-1663172387095.png" alt="SaraJCourter_0-1663172387095.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The current expression our team has now is this&lt;/P&gt;&lt;P&gt;!Longitude![:14] + !Longitude![20:]&lt;/P&gt;&lt;P&gt;This will only cut off the number, not round the 3 to a 4, so this is what we end up with.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaraJCourter_1-1663172495000.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51188i303E6EE5FDE1F99F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SaraJCourter_1-1663172495000.png" alt="SaraJCourter_1-1663172495000.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is a text field, so I'm not sure how we can get this to work. Any ideas would be great!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 17:34:57 GMT</pubDate>
    <dc:creator>SaraJCourter</dc:creator>
    <dc:date>2022-09-14T17:34:57Z</dc:date>
    <item>
      <title>Using Calculate Field to Round Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212564#M59827</link>
      <description>&lt;P&gt;I am using the calculated geometry to get the Lat/Long of my points on a map in DMS. It works well, but I need the seconds rounded to 2 decimal places.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaraJCourter_0-1663172387095.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51187iA6816719F722EC22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SaraJCourter_0-1663172387095.png" alt="SaraJCourter_0-1663172387095.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The current expression our team has now is this&lt;/P&gt;&lt;P&gt;!Longitude![:14] + !Longitude![20:]&lt;/P&gt;&lt;P&gt;This will only cut off the number, not round the 3 to a 4, so this is what we end up with.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaraJCourter_1-1663172495000.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51188i303E6EE5FDE1F99F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SaraJCourter_1-1663172495000.png" alt="SaraJCourter_1-1663172495000.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is a text field, so I'm not sure how we can get this to work. Any ideas would be great!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 17:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212564#M59827</guid>
      <dc:creator>SaraJCourter</dc:creator>
      <dc:date>2022-09-14T17:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field to Round Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212634#M59837</link>
      <description>&lt;P&gt;showing the full logic&lt;/P&gt;&lt;LI-CODE lang="python"&gt;l = '43.03931037'
str(round(float(l), 2))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 19:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212634#M59837</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-09-14T19:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field to Round Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212902#M59870</link>
      <description>&lt;P&gt;I appreciate the help, but unfortunately, this doesn't work for my scenario.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 16:15:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1212902#M59870</guid>
      <dc:creator>SaraJCourter</dc:creator>
      <dc:date>2022-09-15T16:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field to Round Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1366944#M77025</link>
      <description>&lt;P&gt;I was having a similar issue with a dataset of my own, so I wrote a Python expression for use in the Field Calculator that should work whether the cardinal direction letter is before or after the DMS values.&lt;/P&gt;&lt;P&gt;The crux of the issue is that the round() function only works on numbers, not strings, and your input and output (the longitude field) are both strings. &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt; was on the right track with this by using Python type casting to turn the string input into a float number, rounding the float number, then turning that rounded value back into a string. That is what the 4th line of my code is doing. You can change the last number in line 4 to reflect the number of decimal places you wish to round to. To use my code you will need to change the input field name in the first calculation box code to your longitude field name.&lt;/P&gt;&lt;P&gt;I made my code a bit more complicated than necessary so that it would still work whether the cardinal direction letter was before or after the coordinates in the input string. Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in the first calculation box enter:&lt;/P&gt;&lt;P&gt;rounddms(!LAT_DMS!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and in the main code block paste:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def rounddms(lat_str):
    sec_loc = lat_str.find('"')
    min_loc = lat_str.find("'")
    rounded_val = str(round(float(lat_str[(min_loc+1):(sec_loc-1)]),2))
    return_str = lat_str[:(min_loc+1)]+" "+rounded_val+lat_str[sec_loc:]
    return return_str&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Jan 2024 19:31:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-calculate-field-to-round-coordinates/m-p/1366944#M77025</guid>
      <dc:creator>Abigail_K</dc:creator>
      <dc:date>2024-01-05T19:31:09Z</dc:date>
    </item>
  </channel>
</rss>

