Select to view content in your preferred language

Calculate Field Management (x,y) using Python in ArcGIS 10

2620
1
08-23-2010 06:46 AM
EdwardNicholas
New Contributor
I am trying to calculate the x and y coordinates using the Calculate Field tool in ArcToolbox.

The following code works in ArcGIS 9.3.1 but not ArcGIS 10. Any idea as to why it doesn't work? All input data variables are the same.

arcpy.CalculateField_management(BT_BNG, "Eastings", "!shape.firstpoint.x!", "PYTHON", "")

After running the code I receive the following message:

Invalid property firstpoint.x. Valid properties: labelpoint, type, extent, truecentroid, firstpoint, lastpoint, ismultipart, hullrectangle, area, length, partcount, pointcount, centroid
Failed to execute (Calculate Field).
0 Kudos
1 Reply
FrédéricPRALLY
Esri Contributor
Hi Edward,

Try to replace PYTHON by PYTHON_9.3 in the expression type of CalculateField_management.
See sample below:

arcpy.CalculateField_management(BT_BNG, "Eastings", "!Shape.firstPoint.X!", "PYTHON_9.3")


Now the script should run correctly,

Best regards,
Fred
0 Kudos