<?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 Re: Arcpy - Recalculating spatial indexes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682730#M52877</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you run the Rebuild Indexes tool on one data set from ArcCatalog, and then compare that code snippet in the Results window to the call you are using in your code for the same data set, how do they compare?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Mar 2018 16:00:01 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2018-03-01T16:00:01Z</dc:date>
    <item>
      <title>Arcpy - Recalculating spatial indexes</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682729#M52876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I work in database conversions and I've been getting my feet wet in python. My programming skills are very basic but I've been improving. We know the benefits of going into ArcCatalog and recalculating spatial indexes - especially after a conversion, it takes us from an extreme set of extents to something actually reasonable. Subsequent tools and the live software run much faster. Obviously this is low-hanging fruit for a python script and there is probably something already out there, but the practice is worth it to me. The problem is, the code runs but I'm not seeing any changes through ArcCatalog. The "extents" remain unchanged in the spatial index tab. Even empty feature classes retain their extents instead of going to 0/0/0/0. The Recalculate button does make that change - why doesn't my script? This is a SQL database with ESRI 10.2 format (I know, unfortunately I am limited to that version right now).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on examples I found online, I used both RebuildIndexes_management and AnalyzeDatasets_management. The examples I saw fed a list of feature classes into the function once, I'm trying to do it one by one for logging purposes but I'm not sure if that's the best idea. My timestamped logs show each feature class took approximately 30 seconds, whether it was empty or gigantic, and it took four hours to work through the database. And then I don't see any extents change in ArcCatalog. I'm not clear on what I'm doing wrong.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;def &lt;/SPAN&gt;RecalculateSpatialIndexes(databaseFilePath, T, logger):

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = databaseFilePath
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureList = arcpy.ListFeatureClasses()

&amp;nbsp;&amp;nbsp;&amp;nbsp; printLog(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'--------------Beginning to Recalculate Spatial Indexes ---------------'&lt;/SPAN&gt;, T, logger)
&amp;nbsp;&amp;nbsp;&amp;nbsp; printLog(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'FeatureList: ' &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(featureList),T,logger)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;f &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;featureList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printLog(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Recalculating spatial index for: ' &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(f),T,logger)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;try&lt;/SPAN&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RebuildIndexes_management(databaseFilePath, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"NO_SYSTEM"&lt;/SPAN&gt;, f, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ALL"&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printLog(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Running AnalyzeDatasets: ' &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(f),T,logger)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AnalyzeDatasets_management(databaseFilePath, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"NO_SYSTEM"&lt;/SPAN&gt;, f, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ANALYZE_BASE"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ANALYZE_DELTA"&lt;/SPAN&gt;,&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ANALYZE_ARCHIVE"&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;except &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;Exception &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;as &lt;/SPAN&gt;err:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printLog(&lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(err),T,logger)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;break&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:43:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682729#M52876</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T04:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - Recalculating spatial indexes</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682730#M52877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you run the Rebuild Indexes tool on one data set from ArcCatalog, and then compare that code snippet in the Results window to the call you are using in your code for the same data set, how do they compare?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Mar 2018 16:00:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682730#M52877</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-03-01T16:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - Recalculating spatial indexes</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682731#M52878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Running the ArcToolbox equivalent is certainly a good idea. I've done the rebuild indexes and analyze dataset tools, they return successfully just like in my python script, but neither of them are updating the "bounding box" within the spatial index tab. I've tried it on an empty feature class and a populated feature class and it just doesn't change. So it makes sense that the python version isn't doing anything either. I look at SQL Server Management Studio and the spatial index there is also unchanged. I'm having a fundamental misunderstanding here...if it's relevant at all, I'm using standalone feature classes that are not in any datasets, they are registered as versioned with the option to move edits to base.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Mar 2018 20:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-recalculating-spatial-indexes/m-p/682731#M52878</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-03-01T20:41:23Z</dc:date>
    </item>
  </channel>
</rss>

