Zooming in to selected features

Creating selection sets in ArcMap is a common task. Selection sets are often created as the result of an attribute or spatial query, but they can also occur when a user manually selects features and sometimes, under some additional circumstances. To better visualize selection sets, users often zoom to the extent of the selected feature. This can be accomplished programmatically with Python in several ways. In this recipe, you will learn how to zoom to all the selected features in a data frame as well as an individual layer.

Getting ready

The DataFrame.zoomToSelectedFeatures property zooms to the extent of all the selected features from all the layers in the data frame. Essentially, it performs the same operation as ...

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.