Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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). enter image description here

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Do you have a cut-off distance for the how far you wish to search for the closest feature? If so, you might consider using ISpatialCacheManager3 instead. I've heard people have had problems with IFeatureIndex2. Once you've called FillCache, you should be able to quickly return features with IFeatureClass.Search using a small search envelope whose width and height is the size of your cut-off distance and then loop through each feature to find which is the closest.

share|improve this answer
add comment

I've read somewhere that if you set the subfields on the Queryfilter for the feature cursor, to only contain OID field and shapefield should improve the index generation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.