Select to view content in your preferred language

# Line and Polygon with same geometry should have same centroid?

885
6
01-29-2021 09:59 AM
Labels (1)
New Contributor II

Hello,

I have two different line and polygon features with the same geometry. I calculated the X and Y coordinate values using the python expressions !shape.TRUECENTROID.X! and !shape.TRUECENTROID.Y! and the returned values in both features are different.

I'm doing something wrong?

Can any one help me?

Best regards,

JA

Tags (1)
6 Replies
MVP Esteemed Contributor

If you converted the polygon to its polyline representation and if the algorithm used to determine the truecentroid is the same for a closed loop polyline and its polygon representation are the same,... then yes.

However, there is no indication of what is actually used for closed loop polylines, then just indicate polylines, so that may not be the case.  You can experiment to see what value is being returned and compare the results of the center of the x,y coordinates, the centroid and truecentroid for both a closed-loop polygon and its polygon representation.

... sort of retired...
New Contributor II

Dan Patterson,

Both feature where generated/imported from the same DWG file.

The same geometry generated line and polygon objects.

I attached an image,

Best regards,

JA

MVP Emeritus

two different line and polygon features with the same geometry.

Lines and polygons are not the same geometry....

That should just about do it....
MVP Esteemed Contributor

So my initial post stands.  If you need the truecentroid use the polygon if you aren't sure which algorithm is used for closed-loop polylines

... sort of retired...
New Contributor II

Dan Patterson,

You are probably right, but I was hoping that someone from ESRI confirm it!

Even do, all geometries have the same number of points and they should return the same values.

Best regards,

JA

MVP Esteemed Contributor

If you want someone from esri, then the quickest route is to contact Tech Support.

The assumption has nothing to do with the number of points, it is how the points are used.  The only way they would return the same value is if the average of the coordinates were used (perhaps ignoring the duplicate first and last point... even that isn't clear).

The centroid and truecentroid for polygons will also differ for multipart features.  In fact the centroid may not even be within the polygon (or polyline) since they are weighted.  Hopefully you haven't been looking at multipart shapes?

... sort of retired...