Select to view content in your preferred language

How do I add X-COORD and Y-COORD fields to a point feature class?

362
1
08-20-2010 10:15 AM
GordonReese
Emerging Contributor
I am trying to find code in Visual Basic 6.5 that will add (and calculate) X- and Y- coordinate fields to an existing point feature class.  Preferably, there would be a way to do this with shapefiles, but I suspect that I will first need to convert to coverages as this is the data type for which the 'Addxy' command was written.

ArcGIS Desktop help gives the following script example under "Add XY Coordinates (Coverage)(ArcInfo only)":

"import arcgisscripting
gp = arcgisscripting.create()

gp.workspace = "c:/temp"
gp.toolbox = "arc"
gp.addxy("wells", "point")"

Thus far I have been unable to get this to work.  Is there a way to direct the last line to a known coverage, e.g., "gp.addxy('C:\Temp\PtCov', Point)"?

Many thanks in advance!
0 Kudos
1 Reply
GordonReese
Emerging Contributor
Apologies for the original post, I was not aware, obviously, of the 'Add XY Coordinates' tool in "Data Management Tools >> Features".  It is easily implemented in code with:

gp.AddXY_management PtShape
0 Kudos