Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Donald Eric Pimpler, Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Donald Eric Pimpler, Eric Pimpler

Overview of this book

Table of Contents (22 chapters)
Programming ArcGIS with Python Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Referencing the current map document


When running a geoprocessing script from the ArcGIS Python window or a custom script tool, you will often need to make a reference to the map document which is currently loaded in ArcMap. This is typically the first step in your script before you perform geoprocessing operations against layers and tables in a map document. In this recipe, you will learn how to reference the current map document from your Python geoprocessing script.

Getting ready

Before you can actually perform any operations on a map document file, you need to make a reference to it in your Python script. This is done by calling the MapDocument() method on the arcpy.mapping module. You can reference either the currently running document or a document at a specific location on disk. To reference the currently active document, you simply supply the keyword CURRENT as a parameter to the MapDocument() function. This loads the currently active document in ArcMap. The following code example...