# Process: Add Field gp.AddField_management(parcels_shp, "X_COORD", "DOUBLE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "") # Process: Add Field gp.AddField_management(parcels_shp, "Y_COORD", "DOUBLE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field gp.CalculateField_management(parcels_shp, "X_COORD", "!shape.centroid.x!", "PYTHON_9.3", "") # Process: Calculate Field gp.CalculateField_management(parcels_shp, "Y_COORD", "!shape.centroid.y!", "PYTHON_9.3", "")
It seems like the simplest solution is to add X and Y fields to the polygon feature class and calculate the X and & values as you mention.
9.3 code would look something like:# Process: Add Field gp.AddField_management(parcels_shp, "X_COORD", "DOUBLE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "") # Process: Add Field gp.AddField_management(parcels_shp, "Y_COORD", "DOUBLE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field gp.CalculateField_management(parcels_shp, "X_COORD", "!shape.centroid.x!", "PYTHON_9.3", "") # Process: Calculate Field gp.CalculateField_management(parcels_shp, "Y_COORD", "!shape.centroid.y!", "PYTHON_9.3", "")
Once you have those added to the polys as attributes, why not simply use the identify tool?
You can copy and paste the X and Y values from the tool.
If you don't want to see all of the other attributes when you use the identify tool you can "hide" the other attributes from the identify tool by simply unchecking the other attributes in the Field tab of the layer properties.
ArcGIS already has a tool that does this: Feature to Point (requires ArcInfo). Like most tools, it will honor your selection (ie. make points only for those selected polygons). It doesn't automatically pop up the coordinates, however, so you'd have to code that.
ETGeowizard's unregistered version can do this as well, through arcpy, ArcCatalog or ArcMap, and it's free.
The function is called Polygon To Point, i think.
Hope this helps!
ETGeowizard's unregistered version can do this as well, through arcpy, ArcCatalog or ArcMap, and it's free.
The function is called Polygon To Point, i think.
Hope this helps!
Hello Yousaf,
My apologies: I had misread the thread!
ET Geowizards tools does in fact operate on all items of the shape or feature class.
If you want to do it point by point, you could do one of two things:
- As described above, do an AddField followed by a CalculateField, but only on the active layer.
- Create your fields, select the points you're interested in and do the following: Attribute Table - Right Click on X or Y Field - Calculate Geometry... - X / Y Coordinate of Point. The overhead of manually clicking on each point, then activating the tool you had in mind seems comparable in my books to using this built-in function of ArcMap.
I hope this helps! Write back if anything's unclear.