2

This arises from my own question How to handle coordinates accuracy in ArcGIS where I have tried to use the documentation entitled Using geometry objects with geoprocessing tools as a reference.

I have a table with coordinates in degrees:

enter image description here

I created event table and added it to the view with coordinates system 'GCS_NZGD_2000 WKID: 4167 Authority: EPSG'. I converted this single point to shapefile, defined it projection and computed coordinates of the point using 'Add Geometry Attributes' tool. This is resulting table with numbers as expected:

enter image description here

To replicate this in arcpy I've used this code:

corners =[[174.73,-36.76]]
p=[arcpy.PointGeometry(arcpy.Point(*coords)) for coords in corners]
arcpy.CopyFeatures_management(p, "d:/rubbish/points.shp")

I added output 'points.shp' to the view, defined projection and computed coordinates of the point using 'Add Geometry Attributes' tool. This is resulting table:

enter image description here

As one can see from the picture below the distance between 2 supposedly identical points is close to 10 meters:

enter image description here

However when I updated existing dataset with defined projection using

infc =r'd:\scratch\from_xy.shp'
outRows = arcpy.da.InsertCursor(infc,("SHAPE@","X"))
feat = (arcpy.Point(174.73,-36.76),0)
outRows.insertRow(feat)

It worked. Lessons:

  1. Don't use examples similar to the documentation entitled Using geometry objects with geoprocessing tools
  2. Define projection of dataset prior to any games with geometries.

Does the documentation entitled Using geometry objects with geoprocessing tools need to be revised?

  • Are you sure that there's not more decimals in the table? Did you enter those with exactly 2 decimal places? If this is true then it's most troubling, I frequently do XY Event layer > shapefile (I'm doing one at the moment with ~10 million points) in GDA94/MGA Zone 55... 3rd decimal doesn't mean much, but still, the geometries should be exactly where I place them within the limits of IEEE 754 Double Precision Floating Point. Is anyone else experiencing the same phenomenon? – Michael Stimson Mar 17 '15 at 21:41
  • Numbers shown as typed. The thing is, it is working perfectly fine with XY event added as table to frame with known coordinates. It is arcpy causing trouble – FelixIP Mar 17 '15 at 21:42
  • It's blowing my mind! This is fundamental and should just work; perhaps the NZGD has some sort of domain/precision/offset which rounds or offsets the coordinates.. but it shouldn't affect it unless you're calculating the geometry in a different spatial reference. Nicely picked up FelixIP! Thx for the warning. – Michael Stimson Mar 17 '15 at 21:45
  • So that this can be a question rather than a statement, and become answerable (which is the aim of SE), perhaps you can structure it along the lines of "Should the documentation at resources.arcgis.com/en/help/main/10.1/index.html#/… be fixed? – PolyGeo Mar 18 '15 at 0:06
  • @PolyGeo Could you please help me with this modification by editing original? – FelixIP Mar 18 '15 at 0:09
1

As requested ... posting my comment here

Use a spatial reference object, which I think pointgeometry supports, check the help. If a defined coordinate system is not used single precision is used in the calculations. References to this phenomenon are documented on this site and on geonet and a comment isn't the place to put them. No SR... = ... inaccurate results – Dan Patterson 33 mins ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.