null centroids?

807
5
Jump to solution
12-26-2012 09:54 AM
JamieKass
Occasional Contributor
When looping a cursor through a feature class after a Union and querying the Shape field, I found that all polys with shape.area <0.001 had null shape.centroid. When I tried FeatureToPoint on one of them, I got a point result. Where did ArcGIS pull that centroid from? And more importantly, why do these small polys have no centroids in the Shape field?
0 Kudos
1 Solution

Accepted Solutions
MarcoBoeringa
MVP Regular Contributor
It may have something to do with the default tolerance settings since those polygons are so small.


This was something I had been thinking of too, but in some ways, it doesn't make sense. If ArcGIS manages to calculate valid geometry areas and lengths on these extremely small polygons, as visible in the screenshot, why wouldn't it be able to calculate the centroid for the same features?

Anyway, another question is whether you actually WANT to maintain such extremely fine sliver polygons as the result of a Union of two polygon Feature Classes. Personally, unless they contain some absolutely vital attribute information, I would delete them, as there is usually no viable way to display (e.g. on printed paper) them or use them in any meaningful way in subsequent analysis.

Another option to actually avoid the creation of these tiny polygons, is to set a proper cluster tolerance during execution of the Union tool. Enlarge the value of the cluster tolerance up to a point where the tiny sliver polygons are no longer created:

Union (Analysis)
How Union works

A last option to deal with them if you don't want to re-run the Union command, is to first delete the tiny polygons, and then run the Integrate command to accomplish the same thing the cluster tolerance would do during execution of the Union command, that is, remove tiny sliver polygons and shift coordinates of bordering polygons to create a continuous dataset. Please note though, that there is no 100% guarantee that all small gaps have been eliminated unless you test the topology of the dataset afterwards by using the topology tools in ArcGIS, or use a big enough cluster tolerance during Integrate to eliminate them for sure. As a side note: Integrate will delete the small polygons too if within cluster tolerance, so you can opt for not deleting them manually first, but leave it up to the Integrate command to automatically delete the tiny sliver polygons. See the Help pages I linked.

View solution in original post

0 Kudos
5 Replies
MarcoBoeringa
MVP Regular Contributor
Centroids are calculated "on the fly" by ArcGIS and most other GIS/CAD packages based on the coordinates of the polygon, meaning they are not stored as part of the Shape field.

I can't tell you why the shape.centroid request returned null on shapes with very small areas, except wrong syntax in scripting (is this for VBScript, with Python, it should be "!Shape!.Centroid" in the Field Calculator) or a bug concerning these small polygons, or invalid geometries.

Have you run the Check Geometry tool against both the input datasets and the output that caused the issues?
0 Kudos
JamieKass
Occasional Contributor
RepairGeometry did indeed find a number of self-intersections, etc., but I am still left with features with no centroids. I've included a screen shot where I created a new text field called "centroid" and calculated in Python
str(!Shape!.centroid)
to be sure that the cursor wasn't picking up something strange. They indeed have no centroids, and the fc has already has its geometry repaired. I suppose I could select them and use FeatureToPoint, then join back the coordinates, but that seems like a little much. Any ideas? Anyone have this issue before?
0 Kudos
by Anonymous User
Not applicable
It may have something to do with the default tolerance settings since those polygons are so small.  I think a centroid is calculated based on the corners of each polygon (or maybe it's bounding box?).  One thing you can try is to use the "Export Feature Attribute To ASCII" tool under Utilities in the Spatial Statistics tools.  This will export the attribute table (or a selection of the fields) to a text file.  It will automatically generate centroids for each polygon in the table in a "Shape" field. 

You could try to use that tool and choose a field that contains a unique ID for each polygon to export it out to a csv and join that to your table to get centroid values for all features.  I don't know how well this will work but may be worth a try.
0 Kudos
MarcoBoeringa
MVP Regular Contributor
It may have something to do with the default tolerance settings since those polygons are so small.


This was something I had been thinking of too, but in some ways, it doesn't make sense. If ArcGIS manages to calculate valid geometry areas and lengths on these extremely small polygons, as visible in the screenshot, why wouldn't it be able to calculate the centroid for the same features?

Anyway, another question is whether you actually WANT to maintain such extremely fine sliver polygons as the result of a Union of two polygon Feature Classes. Personally, unless they contain some absolutely vital attribute information, I would delete them, as there is usually no viable way to display (e.g. on printed paper) them or use them in any meaningful way in subsequent analysis.

Another option to actually avoid the creation of these tiny polygons, is to set a proper cluster tolerance during execution of the Union tool. Enlarge the value of the cluster tolerance up to a point where the tiny sliver polygons are no longer created:

Union (Analysis)
How Union works

A last option to deal with them if you don't want to re-run the Union command, is to first delete the tiny polygons, and then run the Integrate command to accomplish the same thing the cluster tolerance would do during execution of the Union command, that is, remove tiny sliver polygons and shift coordinates of bordering polygons to create a continuous dataset. Please note though, that there is no 100% guarantee that all small gaps have been eliminated unless you test the topology of the dataset afterwards by using the topology tools in ArcGIS, or use a big enough cluster tolerance during Integrate to eliminate them for sure. As a side note: Integrate will delete the small polygons too if within cluster tolerance, so you can opt for not deleting them manually first, but leave it up to the Integrate command to automatically delete the tiny sliver polygons. See the Help pages I linked.
0 Kudos
JamieKass
Occasional Contributor
Thanks, setting the cluster tolerance avoided the generation of the small polys, which was the origin of the problem. Still a mystery as to why the have no centroids....
0 Kudos