Skip to content

Instantly share code, notes, and snippets.

@knu2xs
Created October 6, 2014 17:04
Show Gist options
  • Select an option

  • Save knu2xs/810e0efae63c78d9b991 to your computer and use it in GitHub Desktop.

Select an option

Save knu2xs/810e0efae63c78d9b991 to your computer and use it in GitHub Desktop.
Demonstration script for arcpy.da.walk
# import modules
import os
import arcpy
# variables
gdb = r'C:\Student\PYTH_20141006\PYTH_dataStudent\IAGL_Lincoln\Lincoln.gdb'
# walk recursively from top level in geodatabase
for dir, dirs, files in arcpy.da.Walk(gdb):
# for every file in this directory or feature dataset
for file in files:
# combine the current directory path and file name to create full path
path = os.path.join(dir, file)
# create describe object for current data object's properties
desc = arcpy.Describe(path)
# if the data type is a feature class
if desc.dataType == 'FeatureClass':
# report the full path and spatial reference wkid of the data
print('{0} - {1}'.format(path, desc.spatialReference.projectionCode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment