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. However, 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... ...

Get Programming ArcGIS with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.