Skip to content

Instantly share code, notes, and snippets.

@nvkelso
Forked from williamscraigm/indexShapefile.py
Created November 16, 2012 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvkelso/4091182 to your computer and use it in GitHub Desktop.
Save nvkelso/4091182 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