AnsweredAssumed Answered

Intersection-geometry has negative area

Question asked by HimBromBeere on May 23, 2016
Latest reply on May 30, 2016 by HimBromBeere

I have a code that looks for parcels that touch another one:


IGeometry parcelGeometry = parcel.GetEsriGeometry();
ISpatialFilter filter = new SpatialFilter
    SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects, 
    Geometry = parcelGeometry

IFeatureCursor cursor = parcelFeatureClass.Search(filter, true);
IFeature feature;

while ((feature = cursor.NextFeature()) != null)
    var geom = (ITopologicalOperator) feature.Shape;
    var intersectGeom = geom.Intersect(parcelGeometry, esriGeometryDimension.esriGeometry2Dimension) as IArea;

(geom as ESRI.ArcGIS.Geometry.IRelationalOperator).Overlaps(parcel.GetEsriGeometry())


When I execute this chunk of code I get an area of intersection of -0.0000000014294918595190997 which is strange for two reasons:

  1. it is negative
  2. it is far beyond the actual cluster-tolerance (set to 0.1mm)

So I assume this is due to the inaccuarcy of type double.


As my actual purpose is on identifying touching geometries I initially used the esriSpatialRelTouches-operator instead of an intersect for the spatial filter which did not return any feature. esriSpatialRelOverlaps however returns the feature. Quite more weird is that when I filter the geometries in ArcMap using select features from ... that touch the boundary of the source-layer I also get the feature of which I thought it touches my source-feature.


When this problem comes due to the inaccuracy of double I wonder if there are any opportunities to trust the touch-operator anyway as it is a quite strict operator asking for an exact solution which double can´t (obviously) handle. However I´d expected that if an intersection is detected between two features that is far beyond the cluster-tolerance (and moreover is negative) the functions of ITopolgicalOperator are smart enough to filter those geometries out.


I provide a shape-file containing the two geometries but I doubt the problem is reproducible as I exported the geometries from an SDE.


EDIT: I also wrote this arcpy-snipped which gave me expected result:

geometries = []
i = 0
for row in arcpy.SearchCursor('LayerWithSelectedFeatures'):
    i = i + 1
area = geometries[0].intersect(geometries[1], 2)
print area.area


This prints out 0.0 as I expected.