Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Donald Eric Pimpler, Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Donald Eric Pimpler, Eric Pimpler

Overview of this book

Table of Contents (22 chapters)
Programming ArcGIS with Python Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using Walk() to navigate directories


In this recipe, you will learn how to generate data names in a catalog tree using the Arcpy Walk() function. Though similar to the Python os.walk() function, the da.Walk() function provides some important enhancements related to geodatabases.

Getting ready

The Walk() function, which is part of arcpy.da, generates data names in a catalog tree by walking the tree top-down or bottom-up. Each directory or workspace yields a tuple containing the directory path, directory names, and filenames. This function is similar to the Python os.walk() function but it has the added advantage of being able to recognize geodatabase structures. The os.walk() function is file-based so it isn't able to tell you information about geodatabase structures while arcpy.da.walk() can do so.

How to do it…

Follow these steps to learn how to use the da.Walk() function to navigate directories and workspaces to reveal the structure of a geodatabase:

  1. In IDLE, create a new Python script called...