Data Access Search Cursor.

What, if anything, is the difference between the tokens "SHAPE@XY" and "SHAPE@TRUECENTROID"?

They returned the same coordnates on a test polygon:

>>> cursor = arcpy.da.SearchCursor("test", "SHAPE@XY")
>>> for row in cursor:
...     print row[0]
(559389.3838043335, 4239093.201390337)

>>> cursor = arcpy.da.SearchCursor("test", "SHAPE@TRUECENTROID")
>>> for row in cursor:
...     print row[0]
(559389.3838043335, 4239093.201390337)

enter image description here

It behaved the same way for a multipart polygon feature. Does it ever return different results?


I was curious as to this as well so I asked around a little and did some research. what I found was

SHAPE@XY —A tuple of the feature's centroid x,y coordinates.
SHAPE@TRUECENTROID —A tuple of the feature's true centroid x,y coordinates.

This article describes how they are identical around 95% of the time but will result in a slight difference the remaining 5%


quoted from the article "So the point of this post is that using the SHAPE@XY token is misleading. It is the same as getting the SHAPE@TRUECENTROID value for X&Y. This is also true of the SHAPE@X or SHAPE@Y. This will cause issues for people who want to geocode address locations and then do any kind of spatial analysis where counting points in parcels is important. There will be odd shaped parcels that should have a point inside but don't, and points in other parcels that shouldn't be there but are placed due to the center of gravity of the odd parcel. I use the SHAPE@ token to avoid this issue, but that means more memory is consumed to hold the entire polygon geom object instead of the just the centroid, which makes for a slower script."

| improve this answer | |

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.