<?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: Field calculator problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432172#M33983</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I've tried all of the suggestions without any luck.&amp;nbsp; The only way that I can get it to extract the data is if I use:&lt;BR /&gt;&lt;BR /&gt; !shape.firstpoint! &lt;BR /&gt;&lt;BR /&gt;What's worse is that I have to have the field type set to text!&amp;nbsp; So, I end up with:&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;-92.298060755811 41.6208860260915 in my destination field.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I have been able to populate my desired fields from these fields and convert it to a double, but it has been a real pain.&lt;BR /&gt;&lt;BR /&gt;I'm running ArcInfo 9.2 does that make a difference on the syntax?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At 9.2 you could not use a method to access the X or Y component of the coordinate directly.&amp;nbsp; That capability first appeared at 9.3.&amp;nbsp; You had to parse the coordinates to get each desired coordinate separated and cast them to a float for directly calculating them to a pair of double fields.&amp;nbsp; That avoids first saving the whole string to a text field.&amp;nbsp; I don't have access to 9.2 anymore, but as I recall the syntax works something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;float(!shape.firstpoint![0]) # for X coordinate.&amp;nbsp; float(!shape.firstpoint![1]) for Y coordinate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Oct 2011 23:24:17 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2011-10-19T23:24:17Z</dc:date>
    <item>
      <title>Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432166#M33977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to do a very simple action using the field calculator. I have a shp file that I want to calculate the start and finish xy coordinates. I have added the new fields and gone into the field calculator throught toolbox and entered:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!shape.firstpoint.x! for the begin_x field but I get the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (CalculateField_28): CalculateField ROUTEM_1_Intersect begin_x !shape.firstpoint.x! PYTHON # ROUTEM_1_Intersect&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Oct 11 17:08:08 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invalid property firstpoint.x. Valid properties: type, extent, centroid, label, firstpoint, lastpoint, area, length, ismultipart, partcount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField_28).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Tue Oct 11 17:08:08 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on what I'm doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 21:10:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432166#M33977</guid>
      <dc:creator>BamJam</dc:creator>
      <dc:date>2011-10-11T21:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432167#M33978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try capitalizing the x (ie X), if memory serves the properties within python are case-sensitive (also check the shape syntax/capitalization&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 21:21:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432167#M33978</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-10-11T21:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432168#M33979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried using the syntax: !SHAPE.firstpoint.X! and got this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (CalculateField_1): CalculateField "J:\Work\North System\ROUTEM_1_Intersect.shp" begin_x !SHAPE.firstpoint.X! PYTHON # "J:\Work\North System\ROUTEM_1_Intersect.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 12 08:22:15 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invalid property firstpoint.X. Valid properties: type, extent, centroid, label, firstpoint, lastpoint, area, length, ismultipart, partcount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(DAO.TableDefs) Item not found in this collection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField_1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Wed Oct 12 08:22:15 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then tried !shape.firstpoint.X! and got this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (CalculateField_2): CalculateField "J:\Work\North System\ROUTEM_1_Intersect.shp" begin_x !shape.firstpoint.X! PYTHON # "J:\Work\North System\ROUTEM_1_Intersect.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 12 08:24:19 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invalid property firstpoint.X. Valid properties: type, extent, centroid, label, firstpoint, lastpoint, area, length, ismultipart, partcount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField_2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Wed Oct 12 08:24:20 2011 (Elapsed Time: 1.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then tried !SHAPE.firstpoint.x! and got:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (CalculateField_3): CalculateField "J:\Work\North System\ROUTEM_1_Intersect.shp" begin_x !SHAPE.firstpoint.x! PYTHON # "J:\Work\North System\ROUTEM_1_Intersect.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 12 08:25:43 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invalid property firstpoint.x. Valid properties: type, extent, centroid, label, firstpoint, lastpoint, area, length, ismultipart, partcount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField_3).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Wed Oct 12 08:25:44 2011 (Elapsed Time: 1.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then !SHAPE.FIRSTPOINT.X! and got:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (CalculateField_4): CalculateField "J:\Work\North System\ROUTEM_1_Intersect.shp" begin_x !SHAPE.FIRSTPOINT.X! PYTHON # "J:\Work\North System\ROUTEM_1_Intersect.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 12 08:26:22 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invalid property FIRSTPOINT.X. Valid properties: type, extent, centroid, label, firstpoint, lastpoint, area, length, ismultipart, partcount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField_4).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Wed Oct 12 08:26:22 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 12:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432168#M33979</guid>
      <dc:creator>BamJam</dc:creator>
      <dc:date>2011-10-12T12:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432169#M33980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management(test_shapefile_path, "test_field", "!shape.firstpoint.x!", "PYTHON_9.3", "")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For some reason, this does not work if the mode is set to "PYTHON." See related post, &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/11476-Calculate-Field-Management-%28x-y%29-using-Python-in-ArcGIS-10"&gt;http://forums.arcgis.com/threads/11476-Calculate-Field-Management-%28x-y%29-using-Python-in-ArcGIS-10&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 16:23:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432169#M33980</guid>
      <dc:creator>RuthEmerick</dc:creator>
      <dc:date>2011-10-12T16:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432170#M33981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem here is that&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;!Shape.firstpoint.X!&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;should be&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;!Shape!.firstpoint.X&lt;/PRE&gt;&lt;SPAN&gt;(notice the '!' placement)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The exclamation marks delineate a field, which is SHAPE here. Once you're looking at the right field, you can access its members' attributes or methods, using the dot notation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Worked like a charm on my PC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best of luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 14:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432170#M33981</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2011-10-13T14:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432171#M33982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've tried all of the suggestions without any luck.&amp;nbsp; The only way that I can get it to extract the data is if I use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; !shape.firstpoint! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What's worse is that I have to have the field type set to text!&amp;nbsp; So, I end up with:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-92.298060755811 41.6208860260915 in my destination field.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been able to populate my desired fields from these fields and convert it to a double, but it has been a real pain.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm running ArcInfo 9.2 does that make a difference on the syntax?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 18:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432171#M33982</guid>
      <dc:creator>BamJam</dc:creator>
      <dc:date>2011-10-19T18:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432172#M33983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I've tried all of the suggestions without any luck.&amp;nbsp; The only way that I can get it to extract the data is if I use:&lt;BR /&gt;&lt;BR /&gt; !shape.firstpoint! &lt;BR /&gt;&lt;BR /&gt;What's worse is that I have to have the field type set to text!&amp;nbsp; So, I end up with:&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;-92.298060755811 41.6208860260915 in my destination field.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I have been able to populate my desired fields from these fields and convert it to a double, but it has been a real pain.&lt;BR /&gt;&lt;BR /&gt;I'm running ArcInfo 9.2 does that make a difference on the syntax?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At 9.2 you could not use a method to access the X or Y component of the coordinate directly.&amp;nbsp; That capability first appeared at 9.3.&amp;nbsp; You had to parse the coordinates to get each desired coordinate separated and cast them to a float for directly calculating them to a pair of double fields.&amp;nbsp; That avoids first saving the whole string to a text field.&amp;nbsp; I don't have access to 9.2 anymore, but as I recall the syntax works something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;float(!shape.firstpoint![0]) # for X coordinate.&amp;nbsp; float(!shape.firstpoint![1]) for Y coordinate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 23:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432172#M33983</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-19T23:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432173#M33984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.CalculateField_management(test_shapefile_path, "LONDD", "float(!shape.firstpoint!.split()[0])", "PYTHON")
arcpy.CalculateField_management(test_shapefile_path, "LATDD", "float(!shape.firstpoint!.split()[1])", "PYTHON")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:25:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432173#M33984</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T19:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator problem</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432174#M33985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good to know that 9.2 doesn't support a method to access xy coordinates directly&amp;nbsp; (maybe one day we will upgrade).&amp;nbsp; I was able to get the data populated, but will try these other methods in the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 14:37:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-problem/m-p/432174#M33985</guid>
      <dc:creator>BamJam</dc:creator>
      <dc:date>2011-10-20T14:37:41Z</dc:date>
    </item>
  </channel>
</rss>

