Spatial index in file GDB question

3891
6
Jump to solution
08-26-2014 02:51 PM
PeterLen
Occasional Contributor

We are using ArcGIS 10.0 and I am using Java ArcObjects to populate file geodatabase feature classes.  My question deals with spatial indexes on those feature classes.  Everything I come across indicates that ArcGIS will automatically add a spatial index to file geodatabase feature classes.  We have several hundred feature classes and an INTERSECTS location search can take a bit of time.  This is what prompted me to start to look into the index thing.  When I look at the feature class properties for one of the feature classes (in ArcCatalog), I can see in the "Indexes" tab that there is a FDO_OBJECTID listed in the Attribute Indexes box and OBJECTID listed below it in the Fields box.  I assume that the FDO_OBJECTID is referring to the feature's shape (geometry) since when I click the Add button (to add a different index), I see other column values likeour custom column attributes and the Shape_Length and Shape_Area, but no SHAPE column.  If that is the case, then I guess the feature classes do have a spatial index set.  When I look at the bottom of the Indexes tab, however, I can see that the 3 grids are all defined with 0.000000 and it has the text "This feature class has a spatial index that will be built later".  This makes me think that it might have a spatial index but that it isn't fully functional.  Based on that information, can someone tell me if my spatial indexes are indeed there and are workring properly as far as you can tell, or do I need to do the "recalculate" on these indexes to get the index(es) in optimal search form.

Thanks - Peter

1 Solution

Accepted Solutions
PeterLen
Occasional Contributor

Tero - That seems to be the case.  If I were to add features to the feature class via ArcMap, the index would be automatically re-calculated, but I guess when adding features under-the-hood via ArcObjects does not automatically do the re-calculation.  I am using Java ArcObjects and the only thing I could find for "rebuilding" the spatial index is to clone the existing index, delete it, and re-create it using the clone but pass in 0 for each of the grids, which forces a re-build.  That code appears to be doing everything as expected so I will just go with that.  I am just surprised that you can't just call some "recalculate()" method on the spatial index itself.

anyway, I guess I am good for now on this subject.  Thanks for the help.

- Peter

View solution in original post

0 Kudos
6 Replies
TeroRönkkö
Occasional Contributor

In file geodatabase FDO_OBJECTID refers to primary key index (objectid field). You can see if you have spatial index on feature class on "Spatial index" group box on the lower half of the index tab on table properties.

It will read something like "This feature class has spatial index names S30_idx" and some details.

Does this help?

0 Kudos
PeterLen
Occasional Contributor

Tero - Thanks for the response.  Yes, the "Spatial Index" box at the bottom of the Indexes tab indicates "This feature class has a spatial index that will be built later" and the three Grid values are all 0.000000.  This made me fel that there may be a spatial index assigned to the feature class, but that it was not functional based on the text that stated "... that will be built later".  As a test, I clicked the Recalculate button to see what would happen.  It did some recalculation I guess because the grid 1 value changed to 340.000000 and the text changed to "This Feature Class  has a spatial index".  Based on this, I have to believe that all of my feature classes have a spatial index but is the equivalent of being empty and that in order to get the index functioning for quicker searches, I need to go through and recalculate them in order to get the efficiency of having an index during searches.  Does that sound about right?

0 Kudos
TeroRönkkö
Occasional Contributor

It sounds right and you can batch build indexes with rebuild indexes geoprocessing tool.

Or you could script rebuild with python - which is advisable if the data updates regularly. Search for "Rebuild indexes" and "Analyze table" tools.

Good luck!

0 Kudos
PeterLen
Occasional Contributor

Tero - That seems to be the case.  If I were to add features to the feature class via ArcMap, the index would be automatically re-calculated, but I guess when adding features under-the-hood via ArcObjects does not automatically do the re-calculation.  I am using Java ArcObjects and the only thing I could find for "rebuilding" the spatial index is to clone the existing index, delete it, and re-create it using the clone but pass in 0 for each of the grids, which forces a re-build.  That code appears to be doing everything as expected so I will just go with that.  I am just surprised that you can't just call some "recalculate()" method on the spatial index itself.

anyway, I guess I am good for now on this subject.  Thanks for the help.

- Peter

0 Kudos
CarstenSchumann
Occasional Contributor

I suppose you won´t need to recalculate the index, at least as I have discovered so far. However you may take a look at this article (it´s for 9.3. but I suppose it will still apply to 10.0)

0 Kudos
PeterLen
Occasional Contributor

Carsten - Yeah, based on the document I may not have to do the recalculation all that often, but I certainly need to do it the first time since none of the indexes are "active".  The index exists but it is essentially empty since all features were added under-the-hood.  I have a Java ArcObjects script that I can use now that will do the recalculation, which essentially deletes the index and then recreates it. 

0 Kudos