ArcGIS Project File – Listing All Feature Classes from Data Source Using ArcPy

arcgis-proarcpy

I am trying to obtain a list of feature classes in an ArcGIS Project file from the data source (not the Map file layer name). I get the code below but this gives me the layer names in the APRX. I need the actual feature class names (as in the data source names).

import arcpy
import os
import glob
import pandas as pd

aprx_dir =  r'H:\007_Services-GV\02_GV_Updates\2201xx_Engineering\*.aprx'

aprx_dict = {}

for aprx_file in glob.glob(aprx_dir):
    aprx = arcpy.mp.ArcGISProject(aprx_file)
    for m in aprx.listMaps():
        print (aprx_file)
        for layer in m.listLayers():
            print (layer)

Best Answer

Replace print(layer) with print(layer.dataSource)