<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Spatial Index is lost but never found unless I restart Arcmap in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/spatial-index-is-lost-but-never-found-unless-i/m-p/323120#M8416</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Odd problem here and I have not found a solution to it. I'm using ArcGIS 10.1, VB .net and the source data is a shapefile.At some point in my tool I add a field using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IFeatureClass.AddField&lt;/SPAN&gt;&lt;SPAN&gt; method and populate it with values but when I add this field it drops the spatial index on the dataset. In ArcMap if I open the Attribute table I see the * in the Shape field which suggests its still there but I know its not. Later on in my tool I test if a dataset has a spatial index, if not I add one. I test if the dataset has a spatial index with the following code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Dim pFeatureClass As IFeatureClass
 pFeatureClass = m_pFeatureLayer_River.FeatureClass
 Dim pIndexes As IIndexes 
Dim pEnumIndex As IEnumIndex 
pIndexes = pFeatureClass.Indexes 
pEnumIndex = pIndexes.FindIndexesByFieldName(pFeatureClass.ShapeFieldName) 
Dim pIndex As IIndex 
pIndex = pEnumIndex.Next 
If pIndex Is Nothing Then 
&amp;nbsp;&amp;nbsp; ' Add Spatial Index 
End If
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This always fails suggesting the spatial index exists but I know it does not as another tool runs very slowly without it.Only when I restart ArcMap, load the shapefile, open attribute table do I see that the * in the shape field has disappeared.So my question is knowing that I use the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IFeatureClass.AddField&lt;/SPAN&gt;&lt;SPAN&gt; method to add a field how do I "refresh" ArcMap to pick up on the fact that the spatial index has been lost and allow my check for spatial index code to work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Sep 2013 15:33:04 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2013-09-25T15:33:04Z</dc:date>
    <item>
      <title>Spatial Index is lost but never found unless I restart Arcmap</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/spatial-index-is-lost-but-never-found-unless-i/m-p/323120#M8416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Odd problem here and I have not found a solution to it. I'm using ArcGIS 10.1, VB .net and the source data is a shapefile.At some point in my tool I add a field using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IFeatureClass.AddField&lt;/SPAN&gt;&lt;SPAN&gt; method and populate it with values but when I add this field it drops the spatial index on the dataset. In ArcMap if I open the Attribute table I see the * in the Shape field which suggests its still there but I know its not. Later on in my tool I test if a dataset has a spatial index, if not I add one. I test if the dataset has a spatial index with the following code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Dim pFeatureClass As IFeatureClass
 pFeatureClass = m_pFeatureLayer_River.FeatureClass
 Dim pIndexes As IIndexes 
Dim pEnumIndex As IEnumIndex 
pIndexes = pFeatureClass.Indexes 
pEnumIndex = pIndexes.FindIndexesByFieldName(pFeatureClass.ShapeFieldName) 
Dim pIndex As IIndex 
pIndex = pEnumIndex.Next 
If pIndex Is Nothing Then 
&amp;nbsp;&amp;nbsp; ' Add Spatial Index 
End If
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This always fails suggesting the spatial index exists but I know it does not as another tool runs very slowly without it.Only when I restart ArcMap, load the shapefile, open attribute table do I see that the * in the shape field has disappeared.So my question is knowing that I use the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IFeatureClass.AddField&lt;/SPAN&gt;&lt;SPAN&gt; method to add a field how do I "refresh" ArcMap to pick up on the fact that the spatial index has been lost and allow my check for spatial index code to work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 15:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/spatial-index-is-lost-but-never-found-unless-i/m-p/323120#M8416</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-09-25T15:33:04Z</dc:date>
    </item>
  </channel>
</rss>

