ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Hilfe
  • Sign Out
ArcGIS Desktop

ArcGIS Online

Die Mapping-Plattform für Ihre Organisation

ArcGIS Desktop

Ein vollständiges professionelles GIS

ArcGIS Enterprise

GIS in Ihrem Unternehmen

ArcGIS for Developers

Werkzeuge zum Erstellen standortbezogener Apps

ArcGIS Solutions

Kostenlose Karten- und App-Vorlagen für Ihre Branche

ArcGIS Marketplace

Rufen Sie Apps und Daten für Ihre Organisation ab.

  • Dokumentation
  • Support
Esri
  • Anmelden
user
  • Eigenes Profil
  • Abmelden

ArcMap

  • Startseite
  • Erste Schritte
  • Karte
  • Analysieren
  • Verwalten von Daten
  • Werkzeuge
  • Erweiterungen

ListBrokenDataSources

  • Zusammenfassung
  • Auswertung
  • Syntax
  • Codebeispiel

Zusammenfassung

Returns a Python list of Layer objects within a map document (.mxd) or layer (.lyr) file that have broken connections to their original source data.

Auswertung

ListBrokenDataSources always returns a Python list object even if only one broken layer is returned. In order to return a single layer object, an index value must be used on the list (e.g., brkLyr = arcpy.mapping.ListBrokenDataSources(mxd)[0]). For loops on a list provide an easy mechanism to iterate through each item in the list (e.g., for brkLyr in arcpy.mapping.ListBrokenDataSources(mxd):).

Some layers within a map document or layer file may be password protected because the user and password information is not saved within the layer file or map document. Map documents that contain these layers typically prompt the user to enter the appropriate information while the document is opening. The arcpy.mapping scripting environment will, by default, supress these dialogs during execution but that means that the layers will be treated as though they have broken data sources. In otherwords, secured layers will not be rendered in any output. If it is necessary for these layers to render appropriately then there are a couple of options. First, save the username and password information with the layers. Second, the CreateArcSDEConnectionFile geoprocessing function allows you to create a connection that is persisted in memory. If this command is used prior to opening a map document (.mxd) with the MapDocument function or a layer file with the Layer function, then SDE layers will render and not appear as broken. Currently, there is not an alternative for secured web services. See the Layer help for a code example.

To learn more about automating the repair of broken layers, refer to: Updating and Fixing Data Sources.

Syntax

ListBrokenDataSources (map_document_or_layer)
ParameterErläuterungDatentyp
map_document_or_layer

A variable that references a MapDocument or Layer object.

Object

Rückgabewert

DatentypErläuterung
Layer

A Python list of Layer objects.

Codebeispiel

ListBrokenDataSources example:

This script will search for broken data sources in all map documents that exist in a single folder. A report with map document names and broken sources will be printed.

import arcpy, os
path = r"C:\Project"
for fileName in os.listdir(path):
    fullPath = os.path.join(path, fileName)
    if os.path.isfile(fullPath):
        basename, extension = os.path.splitext(fullPath)
        if extension == ".mxd":
            mxd = arcpy.mapping.MapDocument(fullPath)
            print "MXD: " + fileName
            brknList = arcpy.mapping.ListBrokenDataSources(mxd)
            for brknItem in brknList:
                print "\t" + brknItem.name
            del mxd

ArcGIS Desktop

  • Startseite
  • Dokumentation
  • Support

ArcGIS Plattform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

Über Esri

  • Über uns
  • Karriere
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Wir sind an Ihrer Meinung interessiert.
Copyright © 2019 Esri. | Datenschutz | Rechtliches