Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Overview of this book

Table of Contents (19 chapters)
ArcPy and ArcGIS – Geospatial Analysis with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling the data frame window extent and scale


In Chapter 8, Introduction to ArcPy.Mapping we started to explore the properties and methods of the data frame. Using the arcpy.Extent object, we were able to set the extent of the data frame to an extent that was hard-coded into the script. However, this does not always capture the entire extent of large census blocks. Using a combination of definition queries and the data frame extent and scale properties, we can avoid these unwanted results.

There are two data frame object methods used to shift the data frame window to the area of interest, in this case the selected census blocks. The first, which we are not using here, is dataFrame.zoomToSelectedFeatures. The second, is to assign the data frame's extent property to the extent of the census block layer after the definition query has been assigned to it.

I prefer the second method, as it will work even when there is no selected census blocks. Also, as the maps that are produced by this script...