Changing the map extent
There will be many occasions when you will need to change the map extent. This is frequently the case when you are automating the map production process and need to create many maps of different areas or features. There are a number of ways that the map extent can be changed with arcpy
. But, for this recipe, we'll concentrate on using a definition expression to change the extent.
Getting ready
The DataFrame
class has an extent
property that you can use to set the geographic extent. This is often used in conjunction with the Layer.definitionQuery
property that is used to define a definition query for a layer. In this recipe, you will learn how to use these objects and properties to change the map extent.
How to do it...
Follow these steps to learn how to get a list of layers from a map document:
Open
c:\ArcpyBook\Ch3\Crime_Ch3.mxd
with ArcMap.Click on the Python window button from the main ArcMap toolbar.
Import the
arcpy.mapping
module:import arcpy.mapping as mapping
Reference...