0

This question links back to an old question of mine: Convert shapefiles in nested folder to geodatabase

I am attempting to find a permanent solution to fixing the broken maps, and in such a way that they can easily be fixed if the maps documents get broken again.

As stated previously, I have hundreds of map documents all with broken data sources. It is not feasible to use findAndReplaceWorkspacePaths because the data is in a multitude of nested folders, not kept in one folder or geodatabase.

To complicate things further, many of the shapefiles used have the same name, but are located in a different folders.

arcpy.mapping.ListBrokenDataSources returns a list of the names of the layers that have a broken data source in the map document, but only the name. Within the map document, if I click on the Source tab of the Layer Properties it shows the 'location' of where the data should be.

I have a copy of all the GIS data from the old computer, so ideally I would be able to do something like OldDataSource.replace ('n:/', 'c:/users/athom/oldGIScomputer/')

Is it possible to use python to get the full 'location' + 'name' of the data in a broken data source?

Does anyone have any suggestions?

4

In answer to your question:

Is it possible to use python to get the full 'location' + 'name' of the data in a broken data source?

This code should do it - just substitute in the full path and name for your MXD

import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd")
brkLayerList = arcpy.mapping.ListBrokenDataSources(mxd)
for lyr in brkLayerList:
    print lyr.dataSource

As an aside, you said:

arcpy.mapping.ListBrokenDataSources returns a list of the names of the layers that have a broken data source

but what arcpy.mapping.ListBrokenDataSources actually returns is a list of the layer objects that have a broken data source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.