Hello i have a point.shapefile with fields: FID:0123..., Shape:Points, CONTOUR:400, 401 etc, X, Y. I want to add x,y coordinates to attribute table from a mosaic, how can i do that?
I tried from field calculator the following script for X and Y fields at 'show codeblock':
Dim dblX As Double
Dim pPoint As IPoint
Set pPoint = [Shape]
dblX = pPoint.X
X=
dblX
but i have always an error 999999. I am using ArcGis 10.2.2. any suggestion?
Solved! Go to Solution.
As Jake mentioned there are numerous different Geoprocessing tools that will do this depending on your own unique conditions....
Have you tried the most simple direct way? Right click on the field you want to populate on your attribute table and choose calculate geometry?
Hi Konstantinos,
There is a Geoprocessing tool that will do this for you:
As Jake mentioned there are numerous different Geoprocessing tools that will do this depending on your own unique conditions....
Have you tried the most simple direct way? Right click on the field you want to populate on your attribute table and choose calculate geometry?
thank you very much sir, it helped me a lot
The code you provide above is from the Making Field Calculations help from ArcGIS 9.3/9.3.1, and therein lies your problem. The code Esri provided was VB/VBA and involved accessing ArcObjects. Starting with ArcGIS 10.0, Esri moved to a VBScript parser instead of a fuller-featured VB/VBA. Although some VB code still works in the code block for the field calculator, the specific code you used doesn't because you can't acess ArcObjects through VBScript.
Even if the code you posted worked, VB support has been on life support for a long time, and you should really consider moving to Python. If you simply change the parser to Python, the following code will work in the expression box (you don't need a code block): !shape.extent.XMax! . Since it seems you are working with points, and single points at that, the extent of the geometry will be the geometry itself. You could also use !shape.firstPoint.X! as well.
You can also do it automatically with Python as I showed in this post: Automatic X and Y in Attribute Table
can i also use compute geometry for that? for each field (x,y )separate?
Not sure to which answer you are replying:
You will have to decide which method suits your specific needs best.