Index creation on a shapefile

1424
3
07-26-2016 12:54 AM
DavideLimosani
Occasional Contributor II


Hi guys,

I would like to add an index to a field in a shapefile. I know that i can get all existing indexes through

IReadOnlyList<Index> idd = featClassDefinition.GetIndexes();

but i haven't been able to find a proper way to add a new index to a field.

Can anyone help me?

Thank you

Davide

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

First of all, there are some restrictions in with shapefiles when creating attribute indexes (see help Pro: Add Attribute Index—Data Management toolbox | ArcGIS for Desktop 😞

Shapefiles don't support multiple indexes, so additional fields will become part of a composite index (that is, an index created on multiple fields in a table).

The GetIndexes will yield a readonly list to with the index position of field. see:

ArcGIS Pro 1.3 API Reference Guide This is not the same as an attribute index. I suppose you can use the tool Add Attribute Index to create the index.

DavideLimosani
Occasional Contributor II

Thank you so much Xander, it was very helpful.

Reading your answer another small question comes to my mind. With arcobjects i have never had the necessity to use tools inside my c# code, because all functionalities were available inside arcobjects. Now i see that in proObjects some basic functionality, like adding an index, are just available with tools. Is this just a temporary condition or it is a long run choice?

Thank you,

Davide

0 Kudos
XanderBakker
Esri Esteemed Contributor

Good question! I wish I had a good answer for you...  One thing for sure is that the object model for Pro will not be as fine grained as ArcObjects is. ArcGIS Pro implements a new vision, where task, tools and for instance automation using arcpy.mp are the new way to go (see also FAQ · Esri/arcgis-pro-sdk Wiki · GitHub​ ). It is still in development, but it is and always will be very different from what ArcObjects is.