Accessing a data frame
The ArcMap table of contents is composed of one or more data frames. Each data frame can contain layers and tables. Data frames can be used to filter lists that are returned from the various list functions such as ListLayers()
. For example, a DataFrame
object can be used as an input parameter to restrict the layers returned by the ListLayers() function to only those layers within a particular data frame. You can also use a DataFrame object to get or set the current map extent, which can be useful when creating map books. In this recipe you will learn how to access data frames from your Python scripts.
Getting ready
The ListDataFrames()
function returns a list of DataFrame
objects. Each data frame can hold layers and tables and can be used to restrict the lists returned by the ListLayers()
and ListTablesViews()
functions.
How to do it...
Follow the steps below to learn how to get a list of layers from a map document:
Open c
:\ArcpyBook\Ch3\Crime_Ch3.mxd
with ArcMap.Click...