How to do 'Target layer(s) has their centroid in the source layer by ArcObjects?

4087
1
01-14-2015 03:44 PM
SteveXu
New Contributor III

ArcObjects 10 has esriSpatialRelEnum 9 Constants. When we use ArcMap 10.2, we can do ‘Select by location’ by  'Target layer(s) has their centroid in the source layer feature’.

is there an equivalent of esriSpatialRelEnum constant in ArcObjects  to 'Target layer(s) has their centroid in the source layer feature' in ArcMap 10.2 Select by Location?

I need to find if the centroid(s) of legal parcel (s)  in one Polygon layer are within the selected Tax parcel polygon in another polygon layer.

I found a very similar discussion "Select by centroid within using ArcObjects" in ESRI Archived Forums, which helps. However, I'd like to have some code snippets to start.  Appreciate your help!

0 Kudos
1 Reply
DuncanHornby
MVP Frequent Contributor

I'm not aware of any enumerate that maps to 'Target layer(s) has their centroid in the source layer feature'.

If you think about it that is a two-stage process. The input feature class could be a point, line or polygon so the first stage would be extract the centroid then do the spatial relationship test.

To get the centroid of a geometry use the interface IArea then you would need to test every point against the input layer using an IspatialFilter. There are many examples on the esri forum for this.

An alternative to using low level Arcobjects is to use the IGeoProcessor and call the the Select Layer by Location tool?

0 Kudos