Is there no esriSpatialRelEnum equivalent to 'if centroid falls within?'

2835
2
08-17-2010 12:30 PM
AZendel
Occasional Contributor III
I need a programatic way to select polygons whose centroid are inside a search polygon.  But looking up esriSpatialRelEnum in the help files doesn't seem to give that option.   esriSpatialRelWithin and esriSpatialRelContains will not work in my case. 

Using ArcObjects, is there another way to do this spatial selection other than ISpatialFilter:SpatialRel = <one of the esriSpatialRelEnum values> ?????

Thanks!

AZ
Reply
0 Kudos
2 Replies
JanDuske
New Contributor
A straigth forward solution might be to do the query in two steps. First use a spatial filter with the EnvelopesIntersect filter type, that gives you a cursor to all the polygons which could have their centroid inside the query Polygon.
Then in step two you take every Polygon you get as a result from step one and run a second spatial filter to check if the current polygons centroid lies within the polygon in question. Maybe not very efficient to use a spatial filter for each polygon-polygon pair, probably the IHitTest result bRightSide could be used for step two, if your polygons are not complex (holes...)
Reply
0 Kudos
SteveXu
New Contributor III

I need to do the same in my ArcEngine application. Yesterday, I posted my question "How to do 'Target layer(s) has their centroid in the source layer by ArcObjects".

Hello JanDuske and GIS developers: Can you provide an code snippets or examples?

Thank you very much.

Reply
0 Kudos