<?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 Re: Calculating lat/long values in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2377#M213</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am not normally a programmer myself, but I've used ESRI's model builder and exported models to python scripts that can be executed as part of a batch file. It's not too hard to do, but I don't see a standard toolbox to use and may need to be handled by python.&lt;BR /&gt;&lt;BR /&gt;Basically I need to build a model to trigger ESRI's "Calculate Geometry" function, returning results in decimal degrees or DMS. I don't see any toolboxes to serve that purpose. After searching online, all I can find are python scripts using the CalculateValue toolbox to return the X-Y values. But they're returned in feet and I need to have decimal degrees.&lt;BR /&gt;&lt;BR /&gt;I found a script that looked like what I needed, but it required the Defense Mapping extension in order to use it, which I don't have. &lt;BR /&gt;&lt;BR /&gt;Any easy answers?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know this post is a couple years old, but I too was looking for a way to automatically populate Lat/Long values with python. Using what Jake described, I took the following approach....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dsc = arcpy.Describe(FC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cursor = arcpy.UpdateCursor(FC, "", "Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shape=row.getValue(dsc.shapeFieldName)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = shape.getPart(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = geom.X&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = geom.Y&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('LONG_DD', x)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('LAT_DD', y)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del cursor, row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this is useful for people.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Dec 2013 13:34:48 GMT</pubDate>
    <dc:creator>RussellProvost</dc:creator>
    <dc:date>2013-12-11T13:34:48Z</dc:date>
    <item>
      <title>Calculating lat/long values</title>
      <link>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2375#M211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not normally a programmer myself, but I've used ESRI's model builder and exported models to python scripts that can be executed as part of a batch file. It's not too hard to do, but I don't see a standard toolbox to use and may need to be handled by python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I need to build a model to trigger ESRI's "Calculate Geometry" function, returning results in decimal degrees or DMS. I don't see any toolboxes to serve that purpose. After searching online, all I can find are python scripts using the CalculateValue toolbox to return the X-Y values. But they're returned in feet and I need to have decimal degrees.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found a script that looked like what I needed, but it required the Defense Mapping extension in order to use it, which I don't have. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any easy answers?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 20:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2375#M211</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-09-22T20:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating lat/long values</title>
      <link>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2376#M212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When calculating area or length for a feature class, the units will be based off of the coordinate system.&amp;nbsp; For example, if your feature class is projected to State Plane Feet the calculated area/length will be in feet.&amp;nbsp; If you use the '&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000003m000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.UpdateCursor&lt;/A&gt;&lt;SPAN&gt;' function you can calculate the area/length based off of another coordinate system.&amp;nbsp; A geographic coordinate system (i.e. WGS 1984) will return the area/length as decimal degrees.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"

fc = "Mains"

rows = arcpy.UpdateCursor(fc, "", "Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj")

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Area_DD = geom.area
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del row, rows &lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The mains feature class is projected to 'NAD_1983_StatePlane_Michigan_South_FIPS_2113_IntlFeet', but I specified the geographic coordinate system 'WGS 1984' within the UpdateCursor function.&amp;nbsp; Now when I calculate the area to field 'Area_DD' it will be in Decimal Degrees rather than feet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:06:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2376#M212</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T20:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating lat/long values</title>
      <link>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2377#M213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am not normally a programmer myself, but I've used ESRI's model builder and exported models to python scripts that can be executed as part of a batch file. It's not too hard to do, but I don't see a standard toolbox to use and may need to be handled by python.&lt;BR /&gt;&lt;BR /&gt;Basically I need to build a model to trigger ESRI's "Calculate Geometry" function, returning results in decimal degrees or DMS. I don't see any toolboxes to serve that purpose. After searching online, all I can find are python scripts using the CalculateValue toolbox to return the X-Y values. But they're returned in feet and I need to have decimal degrees.&lt;BR /&gt;&lt;BR /&gt;I found a script that looked like what I needed, but it required the Defense Mapping extension in order to use it, which I don't have. &lt;BR /&gt;&lt;BR /&gt;Any easy answers?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know this post is a couple years old, but I too was looking for a way to automatically populate Lat/Long values with python. Using what Jake described, I took the following approach....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dsc = arcpy.Describe(FC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cursor = arcpy.UpdateCursor(FC, "", "Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shape=row.getValue(dsc.shapeFieldName)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = shape.getPart(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = geom.X&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = geom.Y&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('LONG_DD', x)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('LAT_DD', y)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del cursor, row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this is useful for people.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 13:34:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-lat-long-values/m-p/2377#M213</guid>
      <dc:creator>RussellProvost</dc:creator>
      <dc:date>2013-12-11T13:34:48Z</dc:date>
    </item>
  </channel>
</rss>

