I’m working on a data inventory project and need to figure out what data sources are being used in a large number of aprx’s. Is there a way to determine the data sources of an ArcGIS project by directing a workbench to an aprx file path?
Sorry, a very brief reply, but i’ll come back later and expand if needed.You can use ArcPy in a PythonCaller to list the layers in an APRX
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/updatingandfixingdatasources.htm
https://chatgpt.com/share/67f84756-d79c-8005-ac73-b522691aa5b5
Hey, I’ve made a python script for a similar project at work. I hope this helps.
import csv, arcpy, datetime, timeaprx = arcpy.mp.ArcGISProject(r'\\network\folder\project.aprx')maps = aprx.listMaps()for map in maps: layers = map.listLayers()out_path = r'\\network\folder'ts = datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d_%H%M%S')csv_file = out_path + r'\aprx_report_' + ts + '.csv'print(csv_file)output = ''output = 'Layer,Group_Layer,Feature_Class,Server\n'def listLayers(): results = '' temp = '' featureLayer = layer.longName.split('\\') if len(featureLayer) > 0: try: datasource = layer.dataSource datasourceProperties = datasource.split(',') d = dict(s.split('=') for s in datasourceProperties) groupLayer = featureLayer del groupLayer[-1] groupLayer = ' >> '.join(groupLayer) temp = (str(layer.name) + ',' + groupLayer + ',' + d.get('Dataset') + ',' + d.get('Server')) results = results + temp + '\n' except: print('failed: ') print(featureLayer) if len(featureLayer) == 0: try: datasource = layer.dataSource datasourceProperties = datasource.split(',') d = dict(s.split('=') for s in datasourceProperties) temp = (str(layer.name) + ',,' + d.get('Dataset') + ',' + d.get('Server')) results = results + temp + '\n' except: print('failed: ') print(featureLayer) return resultsdef listRasters(): results = '' temp = '' featureLayer = layer.longName.split('\\') if len(featureLayer) > 0: try: datasource = layer.dataSource ## print(datasource) datasourceProperties = datasource.split(',') if len(datasourceProperties) > 1 : groupLayer = featureLayer del groupLayer[-1] d = dict(s.split('=') for s in datasourceProperties) temp = (str(layer.name) + ',' + ''.join(groupLayer) + ',' + d.get('Dataset') + ',' + d.get('Server')) results = results + temp + '\n' if len(datasourceProperties) == 1: temp = (str(layer.name) + ',,' + ''.join(datasourceProperties) + ',') results = results + temp + '\n' else: pass except: print('failed: ') print(featureLayer) if len(featureLayer) == 0: try: pass # datasource = layer.dataSource # datasourceProperties = datasource.split(',') # d = dict(s.split('=') for s in datasourceProperties) # temp = (str(layer.name) + ',,,') # results = results + temp + '\n' except: print('failed: ') print(featureLayer) return resultsfor layer in layers: if layer.isGroupLayer == True: pass elif layer.isRasterLayer == True: output = output + listRasters() elif layer.is3DLayer == True: output = output + listLayers() elif layer.isFeatureLayer == True: output = output + listLayers() else: passprint(output)file = open(csv_file, 'w')file.write(output)file.close()print('done')
Thanks @hkingsbury and @koala_pond_03 for the suggestions and examples! I’ll give that a shot!
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.