Walking through a directory to find data
So far, you have been working with single datasets and using ArcPy to do many things that you could do as single tools. The benefit of ArcPy has been in helping you track your tasks and in being able to use Notebooks, which make sharing your analysis easy. However, what about when you have a lot of datasets and need to search through them and organize them, or do analysis on them? This is where the Data Access module comes in.
The first thing to look at in the Data Access module is the walk
function, which will allow you to walk through directories.
arcpy.da.Walk
The Python os
module is one that you have seen in previous chapters. You have used os.path.join
to create a full path of a file from the directory and filename. It also has a walk()
function that will walk through a directory tree and find data. This means that you can run it on a folder and be able to walk through all the data, not just within that folder but within the...