ArcGIS for Desktop

  • Documentation
  • Tarification
  • Support

  • My Profile
  • Aide
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

La plateforme cartographique de votre organisation

ArcGIS for Desktop

Un SIG professionnel complet

ArcGIS for Server

SIG dans votre entreprise

ArcGIS for Developers

Outils de création d'applications de localisation

ArcGIS Solutions

Modèles d'applications et de cartes gratuits pour votre secteur d'activité

ArcGIS Marketplace

Téléchargez des applications et des données pour votre organisation.

  • Documentation
  • Tarification
  • Support
Esri
  • Se connecter
user
  • Mon profil
  • Déconnexion

Help

  • Accueil
  • Commencer
  • Carte
  • Analyser
  • Gérer les données
  • Outils
  • Plus...

ListBrokenDataSources

  • Récapitulatif
  • Discussion
  • Syntaxe
  • Exemple de code

Récapitulatif

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.

Discussion

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.

Syntaxe

ListBrokenDataSources (map_document_or_layer)
ParamètreExplicationType de données
map_document_or_layer

A variable that references a MapDocument or Layer object.

Object

Valeur renvoyée

Type de donnéesExplication
Layer

A Python list of Layer objects.

Exemple de code

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
Vous avez un commentaire à formuler concernant cette rubrique ?

ArcGIS for Desktop

  • Accueil
  • Documentation
  • Tarification
  • Support

ArcGIS Platform

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

A propos d'Esri

  • A propos de la société
  • Carrières
  • Blog des initiés
  • Conférence des utilisateurs
  • Sommet des développeurs
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Confidentialité | Légal