<?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: Python and calculating the X and Y coordinates of line start and line end. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674184#M52132</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;SPAN&gt;- put the '!' around the whole expression and fetch the value from the shape field, i.e., "!SHAPE.FIRSTPOINT.X!"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- your field name goes where "fieldname" is, i.e., "FROM_X"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- no code block, so you don't really need to include the empty string for the 5th param, but this may not matter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- the 'dataset' param is your fc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- remember, all parameters are strings, so you need the quotes (unless you use variables)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Oct 2012 13:28:14 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2012-10-12T13:28:14Z</dc:date>
    <item>
      <title>Python and calculating the X and Y coordinates of line start and line end.</title>
      <link>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674183#M52131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello ArcGIS Forum Users,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been able to use Python to copy a polyline dataset and add four fields (FROM_X, TO_X, FROM_Y, TO_Y) but am having trouble with populating the fields with the appropriate information. I would like to use Python to populate them in the following manner:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM_X = X Coordinate of Line Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TO_X = X Coordinate of Line End&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM_Y = Y Coordinate of Line Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TO_Y = Y Coordinate of Line End&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know it can be done manually by opening the datasets attribute table, right clicking on a field, selecting Calculate Geometry and then the appropriate Property but I would like to have a Python script be able to do this so it can be embedded in a SAS script. The COPY and ADD FIELD Python script works in SAS so I am hoping the CALCULATE FIELD will as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried using the Data Management - Fields - Calculate Field and its Python option for FROM_X using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.CalculateField_management(dataset, fieldname, !FROM_X!.firstpoint.x,"PYTHON_9.3","") &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script runs without errors but does nothing to my dataset. I suspect I am missing a step but do not know what to do next.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any input you may provide is greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg Parent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 12:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674183#M52131</guid>
      <dc:creator>GregParent</dc:creator>
      <dc:date>2012-10-12T12:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python and calculating the X and Y coordinates of line start and line end.</title>
      <link>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674184#M52132</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;SPAN&gt;- put the '!' around the whole expression and fetch the value from the shape field, i.e., "!SHAPE.FIRSTPOINT.X!"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- your field name goes where "fieldname" is, i.e., "FROM_X"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- no code block, so you don't really need to include the empty string for the 5th param, but this may not matter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- the 'dataset' param is your fc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- remember, all parameters are strings, so you need the quotes (unless you use variables)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 13:28:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674184#M52132</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-12T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python and calculating the X and Y coordinates of line start and line end.</title>
      <link>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674185#M52133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try the following:&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(dataset, "FROM_X", !Shape!.firstPoint.X,"PYTHON_9.3","")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since you are calculating the value from the geometry, you will need to use the Shape field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note:&amp;nbsp; Python is case sensitive.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 13:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674185#M52133</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-10-12T13:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python and calculating the X and Y coordinates of line start and line end.</title>
      <link>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674186#M52134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Wayne and Jake. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You both deserve the green check mark for providing the answer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg Parent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 16:50:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-calculating-the-x-and-y-coordinates-of/m-p/674186#M52134</guid>
      <dc:creator>GregParent</dc:creator>
      <dc:date>2012-10-12T16:50:51Z</dc:date>
    </item>
  </channel>
</rss>

