I have a large number of polygon features in a personal geodatabase featureclass. I would like to find the nearest polygon for several points inside an area of interest(the red area in figure).
I found IIndexQuery2.NearestFeature is a good option since it 'Finds the nearest feature in index to the input shape'
as per the documentation.
At present, I do not see any way of utilizing the existing spatial index in the geodatabase through arcobjects. The only option i found is to create a temporary index using IFeatureIndex2.Index method.
My problems are with the IFeatureIndex2.Index method. I only need to index a particular group of features. There is a IFeatureIndex2.FeatureCursor
option which supposedly reduces the number of features indexed. So i passed a featureCursor of the specified area to IFeatureIndex2.But mysteriously, this option only increases the time taken for index creation.
Also the Envelope parameter in the Index method (shown below) does not seem to have an effect on the performance.
public void Index (ITrackCancel pTrackCancel, IEnvelope pQueryingGeometryFullExtent));
It does not matter if null is passed or a valid envelope of Area is passed to this method as parameter. It takes same time to complete.
I tested it on a polygon featureclass with around 100000 features. The Index Method took 4 seconds Index Method with FeatureCursor took 12 seconds.
Can anyone suggest whether I am using the methods in the proper way? I might have to run this on an SDE with millions of features. So I am looking forward to indexing only the particular area so that the nearest feature queries would execute faster.