List the sources of each of the "map layer"

1211
2
09-15-2014 05:01 PM
PierreWeisse
New Contributor

Hello,

I try to get the source of each "map layer".

Does anyone have an idea?

I need a syntax like this:
map layer: ... , source: ...
map layer: ... , source ...

This is the beginning of code

import arcpy, os

path = "....."

for fileName in os.listdir (path):

        fullPath = os.path.join (path, fileName)

        if os.path.isfile (fullPath):

            basename, extension = os.path.splitext (fullPath)

            lyrname = arcpy.mapping.Layer (fullPath)

                lyrlist = arcpy.mapping.ListLayers(lyrname)

                print "Nom du Fichier:   "

                print fileName

                print""

                print "Nom de la couche :  "

                print lyrname

                print""

                print "Couches contenu:   "

                print lyrlist

                print""

RESULT:

Nom du Fichier:  

DTSI_aires_protegees_provinciales.lyr

Nom de la couche : 

aires_protegees_provinciales

Couches contenu:  

[<map group layer u'aires_protegees_provinciales'>, <map layer u'Aires prot\xe9g\xe9es provinciales marines'>, <map layer u'Aires prot\xe9g\xe9es provinciales terrestres'>]

Thank you

0 Kudos
2 Replies
DarrenWiens2
MVP Honored Contributor

Untested, but I would try:

print lyrlist[0].dataSource

Or, loop through your list of layers, changing the index number, instead of [0].

0 Kudos
DanPatterson_Retired
MVP Emeritus

This link Layer information in folders will give you a basis

0 Kudos