Skip to content

Instantly share code, notes, and snippets.

@williamscraigm
Created November 16, 2012 21:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save williamscraigm/4091107 to your computer and use it in GitHub Desktop.
Save williamscraigm/4091107 to your computer and use it in GitHub Desktop.
Build a spatial index for all shapefiles in a directory with ArcGIS
import arcpy
from arcpy import env
import os
# Set the workspace for the ListFeatureClass function
#
env.workspace = "C:\\data\\mydata"
# Use the ListFeatureClasses function to return a list of
# all shapefiles.
#
fcList = arcpy.ListFeatureClasses()
# Create a spatial index for each shapefile
#
for fc in fcList:
arcpy.AddSpatialIndex_management(fc, "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment