<?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 script to alter XY values for a feature in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353885#M12293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To update the shape field you have to create an array and assign it to the shape in the buffer before you write the buffer out. You have created a pnt object and updated that, but have not written it back into the row. If the feature is a polyline or polygon then the object needs to be an array of arrays of points to handle multiparts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;row.feat = pnt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;curA.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also in your search cursor you are mixing the old and new methods, the for loop automatically interates the cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;either &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while row :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.... process&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;....row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cur :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ....process&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Sep 2010 12:57:45 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2010-09-10T12:57:45Z</dc:date>
    <item>
      <title>Python script to alter XY values for a feature</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353884#M12292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script for Arc 10 that is attempting to alter the X and Y values for a feature in a feature class.&amp;nbsp; I am able to get the value of the points.X and point.Y and alter these values.&amp;nbsp; But, I can't figure out how to get the change to be saved in the feature class once the script is completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import arcpy module
import arcpy
 
arcpy.env.overwriteOutput = True

# Script arguments
Dgb2_A = arcpy.GetParameterAsText(0)
Fault_Reconstruction = arcpy.GetParameterAsText(1)


# Local variables:
A_TIM = "C:\\Alamo_Project\\Alamo_Breccia.mdb\\Measured_Sections\\A_TIM"
numFeatures = 0
numFeatures = arcpy.GetCount_management(Fault_Reconstruction)
# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(Fault_Reconstruction, "NEW_SELECTION", "[OBJECTID] = 1")
# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(Dgb2_A, "INTERSECT", Fault_Reconstruction, "", "NEW_SELECTION")
# Process: Copy Features
arcpy.CopyFeatures_management(Dgb2_A, A_TIM, "", "0", "0", "0")
inputFieldX = "Fault_Movement_X"
inputFieldY = "Fault_Movement_Y"
cur = arcpy.SearchCursor(Fault_Reconstruction)
MovementX = 0
MovementY = 0
currentRow = 0
for row in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; MovementX = row.getValue(inputFieldX)
&amp;nbsp;&amp;nbsp;&amp;nbsp; MovementY = row.getValue(inputFieldY)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("X: " + str(MovementX))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Y: " + str(MovementY))
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
curA = arcpy.UpdateCursor(A_TIM)
shapefieldname = arcpy.Describe(A_TIM).shapeFieldName
pnt = arcpy.Point()
newpnt = arcpy.Point()

tempX = 0
tempY = 0


for row in curA:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = feat.getPart()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("X: " + str(pnt.X))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Y: " + str(pnt.Y))
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.X = pnt.X + MovementX
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.Y = pnt.Y + MovementY
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("X: " + str(pnt.X))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Y: " + str(pnt.Y))
&amp;nbsp;&amp;nbsp;&amp;nbsp; curA.updateRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Sep 2010 22:26:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353884#M12292</guid>
      <dc:creator>JosephSheffield</dc:creator>
      <dc:date>2010-09-09T22:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to alter XY values for a feature</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353885#M12293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To update the shape field you have to create an array and assign it to the shape in the buffer before you write the buffer out. You have created a pnt object and updated that, but have not written it back into the row. If the feature is a polyline or polygon then the object needs to be an array of arrays of points to handle multiparts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;row.feat = pnt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;curA.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also in your search cursor you are mixing the old and new methods, the for loop automatically interates the cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;either &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while row :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.... process&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;....row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cur :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ....process&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 12:57:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353885#M12293</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2010-09-10T12:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to alter XY values for a feature</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353886#M12294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;kimo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the input.&amp;nbsp; When I add the row.feat = pnt I get the following error:&amp;nbsp; "&amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (FaultRecTest)."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried feat = pnt.&amp;nbsp; This script runs, but does not alter the location of the feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for pointing out that I was mixing old and new methods for the search cursor.&amp;nbsp; I've only have begun to play with python and C# code for Arc 10.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 14:52:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-to-alter-xy-values-for-a-feature/m-p/353886#M12294</guid>
      <dc:creator>JosephSheffield</dc:creator>
      <dc:date>2010-09-10T14:52:47Z</dc:date>
    </item>
  </channel>
</rss>

