<?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: Want Python code for what Calculate Geonetry tool does for xy to meters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436940#M34353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alice,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Be sure you are requesting to upgrade to 10.2.1 and not just 10.2.&amp;nbsp; This tool just became available at 10.2.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jan 2014 09:53:26 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2014-01-08T09:53:26Z</dc:date>
    <item>
      <title>Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436935#M34348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have points with XY coordinates in GCS84 and need to convert them to meters before extracting raster cell values from the points. I know I can do this with the Calculate Geometry window from the drop-down menu off the field name in the attribute table, but I'd like to add this step into a longer python code after adding the new field. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should be easy, right? The Calculate Geometry window asks for the following input (I've entered mine):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Property: Y Coordinate of Point&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Coordinate System: Use coordinate system of the data frame (PCS:Polar Stereographic)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Units: Meters &lt;M&gt;&lt;/M&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for any ideas or help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Alice&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jan 2014 04:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436935#M34348</guid>
      <dc:creator>AOrlich</dc:creator>
      <dc:date>2014-01-07T04:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436936#M34349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Alice,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do this using the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;UpdateCursor&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; You can specify a coordinate system that's in meters.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = "Points"

sr = arcpy.SpatialReference(3032)

with arcpy.da.UpdateCursor(fc, ["SHAPE@XY", "XCOORD", "YCOORD"], "", sr) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = row[0][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = row[0][1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)

del row, cursor&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find the code of your coordinate system within the data frame properties &amp;gt; Coordinate System tab:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30312[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:34:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436936#M34349</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T19:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436937#M34350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Alice,&lt;BR /&gt;&lt;BR /&gt;You can do this using the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;UpdateCursor&lt;/A&gt;.&amp;nbsp; You can specify a coordinate system that's in meters.&amp;nbsp; Ex:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = "Points"

sr = arcpy.SpatialReference(3032)

with arcpy.da.UpdateCursor(fc, ["SHAPE@XY", "XCOORD", "YCOORD"], "", sr) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = row[0][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = row[0][1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)

del row, cursor&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;You can find the code of your coordinate system within the data frame properties &amp;gt; Coordinate System tab:&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]30312[/ATTACH]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition to the above, you can also set the Transformation environment setting prior to opening your cursor and the transformation will be applied (you don't have to reference the transformation in the cursor set up).&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.geographicTransformations = "NAD_1983_To_WGS_1984_5"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also wanted to mention that if you use a cursor with an alternative spatial reference on an XY Event Layer, the original layer coordinates in the table will automatically be converted just by opening the cursor even if you don't loop through any records.&amp;nbsp; That behavior is potentially useful if you wanted the coordinates overwritten in their original fields anyway, but dangerous if you meant to keep the original spatial reference coordinate values and assign the transformed coordinates to another set of fields.&amp;nbsp; To only transform coordinates in a new set of fields in an XY Event layer you should create the new coordinate fields in the table, duplicate the original spatial reference coordinates from the original fields into the new fields, create the XY Event layer using the new fields for the coordinates and the original spatial reference of those coordinates, and then apply the cursor with the alternative spatial reference.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:34:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436937#M34350</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T19:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436938#M34351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, if you upgrade to 10.2.1, there is a new tool called &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000191000000"&gt;Add Geometry Attributes&lt;/A&gt;&lt;SPAN&gt; that will do this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jan 2014 15:14:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436938#M34351</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-01-07T15:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436939#M34352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello again~&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your quick replies. I did try to apply the script you provided after combining both of your suggestions and got some runtime errors, a few that were typos, but the final claimed the field is not nullable (my Lon_M field). I have a IT order in and hope someone will update my license to 10.2 so I can work directly with the Add Geometry Attributes tool!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I don't get the update in the next few days, I might have to ask for more specific direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alice&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2014 00:58:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436939#M34352</guid>
      <dc:creator>AOrlich</dc:creator>
      <dc:date>2014-01-08T00:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Want Python code for what Calculate Geonetry tool does for xy to meters</title>
      <link>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436940#M34353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alice,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Be sure you are requesting to upgrade to 10.2.1 and not just 10.2.&amp;nbsp; This tool just became available at 10.2.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2014 09:53:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-python-code-for-what-calculate-geonetry-tool/m-p/436940#M34353</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-01-08T09:53:26Z</dc:date>
    </item>
  </channel>
</rss>

