<?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 Round or truncate latitude and longitude fields and convert to string with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051321#M60897</link>
    <description>&lt;P&gt;This seems like it should be an EASY thing to do in Python, but it is driving me crazy.&amp;nbsp; (This was so easy to do in VB!)&amp;nbsp; I have latitude and longitude fields (double) with&amp;nbsp; 6 or decimals.&amp;nbsp; I want to round or truncate the number of decimals to 5 decimals and then convert the resulting number to a string field.&lt;/P&gt;&lt;P&gt;I can use the str() option to convert the latitude field to string without a problem, but the negative sign causes an issue with the longitude conversion.&amp;nbsp; If I multiple my (all negative) longitude values by -1 I can get all positive text values in the new text field.&amp;nbsp; But when I try to add the negative sign back to the new text field, I get inconsistent results.&amp;nbsp; Some of the rows update with the negative and some don't.&amp;nbsp; Even if this method did work, this still doesn't solve my need to truncate the decimals to 5 instead of 6 decimals for both the X and Y text fields.&amp;nbsp; I have hundreds of thousands of rows in the data so I need an efficient way to convert the field values.&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="latlong.jpg" style="width: 458px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/11857iF758BC7B7545F6BE/image-dimensions/458x87?v=v2" width="458" height="87" role="button" title="latlong.jpg" alt="latlong.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2021 14:54:57 GMT</pubDate>
    <dc:creator>SusanZwillinger</dc:creator>
    <dc:date>2021-04-26T14:54:57Z</dc:date>
    <item>
      <title>Round or truncate latitude and longitude fields and convert to string with Python</title>
      <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051321#M60897</link>
      <description>&lt;P&gt;This seems like it should be an EASY thing to do in Python, but it is driving me crazy.&amp;nbsp; (This was so easy to do in VB!)&amp;nbsp; I have latitude and longitude fields (double) with&amp;nbsp; 6 or decimals.&amp;nbsp; I want to round or truncate the number of decimals to 5 decimals and then convert the resulting number to a string field.&lt;/P&gt;&lt;P&gt;I can use the str() option to convert the latitude field to string without a problem, but the negative sign causes an issue with the longitude conversion.&amp;nbsp; If I multiple my (all negative) longitude values by -1 I can get all positive text values in the new text field.&amp;nbsp; But when I try to add the negative sign back to the new text field, I get inconsistent results.&amp;nbsp; Some of the rows update with the negative and some don't.&amp;nbsp; Even if this method did work, this still doesn't solve my need to truncate the decimals to 5 instead of 6 decimals for both the X and Y text fields.&amp;nbsp; I have hundreds of thousands of rows in the data so I need an efficient way to convert the field values.&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="latlong.jpg" style="width: 458px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/11857iF758BC7B7545F6BE/image-dimensions/458x87?v=v2" width="458" height="87" role="button" title="latlong.jpg" alt="latlong.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 14:54:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051321#M60897</guid>
      <dc:creator>SusanZwillinger</dc:creator>
      <dc:date>2021-04-26T14:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Round or truncate latitude and longitude fields and convert to string with Python</title>
      <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051325#M60898</link>
      <description>&lt;P&gt;&lt;A href="https://www.w3schools.com/python/ref_func_round.asp" target="_blank"&gt;Python round() Function (w3schools.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 14:59:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051325#M60898</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-04-26T14:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Round or truncate latitude and longitude fields and convert to string with Python</title>
      <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051334#M60899</link>
      <description>&lt;P&gt;Hi David, the rounding is not the problem.&amp;nbsp; The issue is doing the rounding and the conversion to text with a single calculation when you have negative decimal numbers.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 15:05:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051334#M60899</guid>
      <dc:creator>SusanZwillinger</dc:creator>
      <dc:date>2021-04-26T15:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Round or truncate latitude and longitude fields and convert to string with Python</title>
      <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051339#M60900</link>
      <description>&lt;P&gt;Hi Susan - I just tested the following and it worked. I didnt need to use str() as Pro recognised I was trying to convert to a string type automatically.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HamishMorton_0-1619449648384.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/11860i04C0DC92FD884187/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HamishMorton_0-1619449648384.png" alt="HamishMorton_0-1619449648384.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure if you are using field calculator or running this as part of a larger script.&lt;/P&gt;&lt;P&gt;Hamish&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 15:08:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051339#M60900</guid>
      <dc:creator>HamishMorton</dc:creator>
      <dc:date>2021-04-26T15:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Round or truncate latitude and longitude fields and convert to string with Python</title>
      <link>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051347#M60901</link>
      <description>&lt;P&gt;Hi Hamish and David,&amp;nbsp; You are, of course, both correct.&amp;nbsp; There was no need to convert the negative number to text.&amp;nbsp; I was making this more complicated than it needed to be!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 15:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-or-truncate-latitude-and-longitude-fields/m-p/1051347#M60901</guid>
      <dc:creator>SusanZwillinger</dc:creator>
      <dc:date>2021-04-26T15:17:52Z</dc:date>
    </item>
  </channel>
</rss>

