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

Filtering tool messages by the level of severity

As I mentioned in the last recipe, all tools generate a number of messages that can be classified as information, warnings, or error messages. The GetMessages() method accepts a parameter that allows you to filter the messages that are returned. For example, you may not be interested in the informative or warning messages in your script. However, you will certainly be interested in error messages as they indicate a fatal error that will not allow a tool to successfully execute. Using GetMessages(), you can filter the returned message to include only error messages.

Getting ready

Messages are classified into one of three types, which are indicated by the level of severity. Informational messages provide descriptive information concerning things, such as a tools progress, start and end times of the tool, output data characteristics, and much more. The severity of an informational message is indicated by a value of 0. Warning messages are generated...