Mean Center (Spatial Statistics) tool xcoord and ycoord

562
2
11-08-2011 12:12 AM
StephenKing
New Contributor III
Hi,

I am using the Mean Center (Spatial Statistics) tool to calculate the mean center point for a group of seabed samples taken at different sample stations. The tool is working okay but I have found that the output xcoord and ycoord values are not always the same as when the x and y coord of the new point is calculated using the Add XY Coordinates tool - there is often a difference of several meters. The data and data frame are both set to WGS84 UTM Zone 31N and I don't understand why there is this difference. The calculated xcoord and ycoord from the Mean Center tool doesn't seem to be correct for the new point features. Can anyone explain?

Thanks,
Stephen
0 Kudos
2 Replies
LaurenRosenshein
New Contributor III
Hi Stephen,

Sorry that you've run into this issue!  Actually, this sounds like a known issue that is on our list of bugs to fix.  Basically, what's happening is that we are doing all of the mathematical calculations using double precision, and that is what's used to create the actual geometry of the output feature.  The bug is that we are creating the xcoord field and the ycoord field as "Floats" with only single precision, which is why you're seeing differences when you run the Add XY Coordinates tool.  So, the true geometry of the feature is correct, but we are missing precision in the fields where we write the coordinates. 

If you don't mind, we'd like to see if a simple code change will fix this issue for you.  You'll have to find the MeanCenter.py file, which will be located here: C:\Program Files (x86)(**Or wherever you have ArcGIS installed)**\ArcGIS\Desktop10.1\ArcToolbox\Scripts. 

1.  The first thing to do is rename that file to MeanCenter_Orig.py (this way you'll have the original saved somewhere just in case)

2.  Then, open up the MeanCenter_Orig.py, and do a "Save As" and name it MeanCenter.py (the file has to have this name to be found by the Mean Center tool, so you'll want to make sure the file you update has this name)

3.  Once you've done this, do a search for the words "Add Field Names".  In this section of the code you will see something that looks like this:

for fieldName in dataFieldNames:
        UTILS.addEmptyField(outputFC, fieldName, "FLOAT")

4.  What you want to do is change the word "FLOAT" to "DOUBLE". 

5.  Save your changes.

Once you've made the change the xcoord and ycoord fields should be created as doubles, which means that they should have the right precision and you should no longer see any difference from when you run the Add XY Coordinates tool.  If you are still seeing differences, please let us know so that we can figure out what's going on!

Thanks so much for bringing this to our attention, and again I'm very sorry that you've run into this!

Lauren Rosenshein
Geoprocessing Product Engineer
0 Kudos
StephenKing
New Contributor III
Hi Lauren,

Thank you for your reply and your help. The fix that you provided has solved the problem that I was having - the XCoord and YCoord fields generated by the Mean Center tool now match those generated by the Add XY Coordinates tool.

Kind regards,
Stephen
0 Kudos