Query SpatialRelationship esriSpatialRelContains

2979
3
11-25-2011 10:03 AM
DaveOrlando
Occasional Contributor III
Hello,

Quick question, I hope.....

I am tying a spatial query using esriSpatialRelContians, but it seems like the features that are not completely within, are being missed. The description reads 'part or all' of a feature.

Am I overlooking something?....

In the picture, Purple is the boundary (geometry being passed in) and you can see the Cyan is what is returned, but my border polygons are being missed.

private void FindParcelsInLSA(ESRI.ArcGIS.Client.Geometry.Geometry geom)
        {
            QueryTask ParcelByLSA = new QueryTask(string.Format("http://www.{0}.com/rdcoags/rest/services/GIS_App_BASE/MapServer/11", urlClass.RDCO_URL));
            ParcelByLSA.ExecuteCompleted += new EventHandler<QueryEventArgs>(ParcelByLSA_ExecuteCompleted);
            ParcelByLSA.Failed += new EventHandler<TaskFailedEventArgs>(ParcelByLSA_Failed);

            Query q = new Query();
            q.ReturnGeometry = true;
            q.OutFields.Add("*");
            q.Geometry = geom;
            q.SpatialRelationship = SpatialRelationship.esriSpatialRelContains;

            ParcelByLSA.ExecuteAsync(q);
        }
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
Did you try with 'esriSpatialRelIntersects ' as spatial relationship option?

This should select all polygons intersecting your boundary (instead of all polygons completely contained in the boundary)
0 Kudos
WeifengHe
Esri Contributor
I don't know which version you are using.  With ArcGIS 10.0, the SDK help for esriSpatialRelContains
read like this and less confussing:

Returns a feature if its shape is wholly contained within the search geometry. Valid for all shape type combinations.
0 Kudos
DaveOrlando
Occasional Contributor III
Thanks,

Yes it was the description that was confusing me a bit. 'Part or all of a feature' makes it sound like it is somehow using the centroid to grab features that are partially contained.

After testing different relationships in ArcMap I see that my assumptions are wrong, and it is the Intersect that I want to use as suggested. Although because my input geomerty uses coincidental lines as my select layer (but maybe not topologically perfect), this will select external polygons that I don't want. I ended up running a negative buffer on my input geometry before the final query with Intersect.

thanks again
0 Kudos