Chapter 3. Finding and Fixing Broken Data Links

In this chapter, we will cover the following recipes:

  • Finding broken data sources in your map document and layer files
  • Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths()
  • Fixing broken data sources with MapDocument.replaceWorkspaces()
  • Fixing individual layer and table objects with replaceDataSource()
  • Finding broken data sources in all map documents in a folder

Introduction

It is not uncommon for your GIS data sources to move, migrate to a new data format, or be deleted. The result can be broken data sources in many map documents or layer files. These broken data sources can't be used until they're fixed, which can be an overwhelming process if the same changes need to be made across numerous map documents. You can automate the process of finding and fixing these data sources using arcpy.mapping, without ever having to open the affected map documents. Finding broken data sources is a simple process requiring the use of the ListBrokenDataSources() function, which returns a Python list of all broken data sources in a map document or layer file. Typically, this function is used as the first step in a script that iterates through the list and fixes the data source. Fixing broken data sources can be made in an individual data layer or across all layers in a common workspace.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset