Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Eric Pimpler

Overview of this book

The book kicks off with the fundamentals of starting to use Python with ArcGIS, followed by recipes on managing map documents and layers, including how to find and fix broken data links in these files. In the second part of the book, you will learn to create custom geoprocessing tools and how to use the Attribute and Location tools to select specific features. The third part of the book covers topics for advanced users including the REST API, and also teaches you how to use Python with ArcGIS Pro. The book finishes with appendices covering how to automate Python scripts, and the five things that should be at the back of every GIS programmer's mind.
Table of Contents (17 chapters)
16
Index

Retrieving tool messages with GetMessages()


ArcPy includes a GetMessages() function that you can use to retrieve messages generated when an ArcGIS tool is executing. Messages can include informational messages, such as the start and ends times of a tool execution as well as warnings and errors, which can result in something less than the desired result or complete failure of the tool to execute to completion.

Getting ready

During the execution of a tool, various messages are generated. These messages include informational messages, such as the start and end times of a tool execution, parameter values passed to the tool, and progress information. In addition to this, warnings and errors can also be generated by the tool. These messages can be read by your Python script, and your code can be designed to appropriately handle any warnings or errors that have been generated.

ArcPy stores the messages from the last tool that was executed and you can retrieve these messages using the GetMessages(...