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

Finding broken data sources in your map document and layer files


Broken data sources are a very common problem with map document files. You can use arcpy.mapping to identify data sources that have moved, been deleted, or changed in their format.

Getting ready

In ArcMap, a broken data connection is signified by a red exclamation point just before the layer name. This is illustrated in the following screenshot. The ListBrokenDataSources() function in arcpy.mapping returns a list of layer objects from a map document or layer file that have a broken data connection:

How to do it…

Follow these steps to learn how to find broken data sources in a map document file.

  1. Open C:\ArcpyBook\Ch3\Crime_BrokenDataLinks.mxd in ArcMap.

    You will see that each of the data sources have been broken. In this case, the data has been moved to another folder, but you'd see the same indicator if the data had been deleted or migrated to a different format. For example, it is not uncommon to convert data from a personal geodatabase...