Select to view content in your preferred language

How to get features not getting intersected in arcobjects

6605
10
Jump to solution
05-01-2015 06:03 AM
akshayloya
Frequent Contributor

Hi all,

I have two feature classes. I'm intersecting both of them. I have to return features which does not intersect with the other.

Lets take an example.

I have two feature classes: villages and colleges. I'm intersecting both of them.

My query is "Select villages having population greater then 500 not having colleges."

So villages having population greater then is working finely but then it spatially search for colleges in those villages.

what all I need is to select villages which does not have colleges.

Any help would be appreciable. Thanx in advance

Regards

0 Kudos
1 Solution

Accepted Solutions
JavierArtero
Occasional Contributor

Hi again Akshay,

When you call FillCache method in ISpatialCacheManager, you must specify the extent of the cache as a parameter.

You can pass any extent you want.

It could be the visible extent, which can be obtained via IActiveView.Extent at ArcObjects Help for .NET developers.

Or could be the map's area of interest (IMap.AreaOfInterest at ArcObjects Help for .NET developers)

Or whichever IEnvelope you create.

Hope this will be of help. Good luck.

View solution in original post

0 Kudos
10 Replies
JoshuaBixby
MVP Esteemed Contributor

This can be accomplished in two steps using Select By Attribute and Select By Location in ArcMap.  First, select all villages having greater than 500.  Then, "remove from currently selected features..." the villages that have colleges in them.

If scripting, something like:

arcpy.SelectLayerByAttribute_management("villages","NEW_SELECTION", "population > 500")
arcpy.SelectLayerByLocation_management("villages", "INTERSECT", "colleges", "", "REMOVE_FROM_SELECTION")
0 Kudos
akshayloya
Frequent Contributor

Hi Joshua,

I needed solution for arcobjects.

Thanx for the reply though.

Regards

OwenEarley
Frequent Contributor

You can use the same tools in ArcObjects using the Geoprocessor managed assembly - for example:

          

            using ESRI.ArcGIS.Geoprocessor;
            using ESRI.ArcGIS.DataManagementTools;
            ...

            gp = new Geoprocessor();

            var tool = new SelectLayerByAttribute();
            tool.in_layer_or_view = "villages";
            tool.selection_type = "NEW_SELECTION";
            tool.where_clause = "population > 500";
            gp.Execute(tool, null);
JoshuaBixby
MVP Esteemed Contributor

Ah, right, my bad.  One of my streams aggregated your post, and I didn't pay close enough attention that you were focused on ArcObjects.  As Javier Artero​ points out, a disjoint mask as he provides should get you on the right path. 

0 Kudos
JavierArtero
Occasional Contributor

If you are using the SpatialFilter object via the ISpatialFilter interface, you will need to define your own SpatialRelDescription, since the SpatialRel enumeration doesn't have the relationship you need.

You can query the features that doesn't intersect the query geometry setting the SpatialRel property to esriSpatialRelRelation

and SpatialRelDescription property to "FF*FF****"

More information at: SpatialRelDescription on ArcObjects 10 .NET SDK Help

akshayloya
Frequent Contributor

Thanks Javier.

0 Kudos
akshayloya
Frequent Contributor

Any Idea How can I improve performance of my spatial query?

0 Kudos
JavierArtero
Occasional Contributor

You could try using a spatial cache. This should take the data from the geodatabase and put it in memory, thus having a faster access since the queries won't be doing roundtrips to the file system.

Take a look at: ISpatialCacheManager at ArcObjects Help for .NET developers

akshayloya
Frequent Contributor

Hi Javier,

I'm new to arcobjects.

May be a silly question but can you please tell me how to set the Cache extent. Like they have used in the link which you have provided.

0 Kudos