ArcObjects spatial query using IRelationalOperator

2662
2
Jump to solution
09-03-2014 03:48 PM
DamolaMoronkeji
New Contributor

Hi there,

I'm trying to write a C# ArcObjects code to do the following:

1) draw a polygon around an area and store that area values in a field in a polygon feature class e.g. polygon X

2) within the polygon X, do a spatial query using TWO source feature classes i.e. source A and source B

3) source A feature class has identical fields as source B feature class, but the records contained in them are different

4) source A feature class and source B feature class usually have overlapping polygons, hence why spatial query is necessary to identify the overlap area and store this value in another field in polygon X.

Is it possible to do a spatial query based on two sources and one target layer?

this is not possible using "select by location" tool in ArcMap, but can ArcObject IRelationalOperator interface do this?

the examples I have seen so far only shows query between a target layer and a source layer.

Many thanks for your feed backs.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Frequent Contributor

OK so you've drawn polygon X, in this example polygons A and B overlap  and polygon X overlaps these, so which takes precedence? Do you take the information from A or B? If you say the top one then that is dictated by the draw order which I understand is simply the row order in the FeatureClass.

The interface IRelationalOperator compares individual geometries rather than whole layers. As your A and B layer polygons occupy the same space a spatial query will always return both but it would be a layer at a time, so there is no tool that will query 2 sources simultaneously.

I think the bigger problem is how do you decide to choose A over B or vice versa?

View solution in original post

2 Replies
DuncanHornby
MVP Frequent Contributor

OK so you've drawn polygon X, in this example polygons A and B overlap  and polygon X overlaps these, so which takes precedence? Do you take the information from A or B? If you say the top one then that is dictated by the draw order which I understand is simply the row order in the FeatureClass.

The interface IRelationalOperator compares individual geometries rather than whole layers. As your A and B layer polygons occupy the same space a spatial query will always return both but it would be a layer at a time, so there is no tool that will query 2 sources simultaneously.

I think the bigger problem is how do you decide to choose A over B or vice versa?

View solution in original post

DamolaMoronkeji
New Contributor

Thanks a million Duncan for your answer.

Each time I run the code, it only favours polygon A, which seats on top of polygon B. So it's not even possible to use polygon B to return any values from the spatial query but only returns zero all the time.

I just needed to hear it from someone as I thought I was going crazy.

I have been having sleepless nights over this lol.

Many thanks.

0 Kudos