Attribute table empty after replacing data source

4553
9
Jump to solution
11-13-2015 06:39 PM
MarcelAfif
New Contributor III

I replaced the data source for a bunch of layers in my ArcMap document, and saved a copy of the original document. Now, when I open the copy, the properties of the layers indicate that each of these layers does in fact point to the new data source, but the attribute table is empty and consequently ArcMap draws nothing! The strange part is that when I click Add Data, and choose the new data, I get the expected attributes table and ArcMap draws the desired features!

Why am I having this problem?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RebeccaStrauch__GISP
MVP Emeritus

Marcel, so it looks like changing the name of the .gdb is the issue.  That all makes sense if you look at the help Updating and fixing data sources with arcpy.mapping—Help | ArcGIS for Desktop

  • findAndReplaceWorkspacePath or findAndReplaceWorkspacePaths allows you to substitute an entire or partial string for a layer or table's workspace path. It can't be used if the workspace type or dataset name has changed. It is ideal for scenarios where drive letters change, switch to UNC paths, update SDE connection file information, and so on. See the Common Scenarios section below.

i went thru quite a few tests to before it was able to get all my sources to change in my addin, and one thing I found is, even if your save doesn't give an error, if it isn't just perfect (i.e. Correct replacement) the save doesn't work.   I use several different methods to get the various paths to change. So, what you are seeing us "as design", for better or worse.

View solution in original post

9 Replies
JayantaPoddar
MVP Esteemed Contributor

Is there any definition query defined for the layers? Alternatively, you could add the new data to ArcMap. Then, export the symbology of the previous layers to the new layers.



Think Location
MarcelAfif
New Contributor III

I was actually thinking of doing that after I gave up. Nonetheless, I felt I had to find out what's going on because it's not been long since I picked up ArcGIS. Thanks.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Are the new data source formats exactly the same as before? As Jayanta pointed out if you have a query defined, that could cause issues, especially if you are querying a fieldname that has changed.  Also, is the datatype the same? changing the data type can also cause issues.

fwiw, I have a Arcpy addin that helps some for changing data sources. Python addin for data inventory and “broken-link” repair.   Is not perfect, which is why it's a blog and not in arc scripts yet, and focuses on broken links, but could be adapted to change all thinks if needed.  I'm still working on the tool to make additions, but what is there does work.

MarcelAfif
New Contributor III

Hi Rebecca,

There are no queries defined. I tried replacing data via python first, then manually from the  Source tab in Layer Properties, then from ArcCatalog. The last solution tells me that it's better to save a copy, but when I open the copy, the data sources haven't changed.

I'm thinking one reason might be because I don't have admin privileges.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

You shouldn't need admin permissions to save a copy of the mxd, as long as you have permissions to where you are saving it, however, you do need access to the resourcd.  Is it not saving the new path at all when you use the source wizard in catalog?  Maybe you aren't saving them with a compatible data type.  If you select multiple layers and then try to replace a path using that tool, the layers all need to be relative to each other.

can you show a sample of what you are changing from/to?  If you are in the mxd, you said you can change the source without issue.....maybe looking closer at what works will show why the other steps don't work.

0 Kudos
MarcelAfif
New Contributor III

So I narrowed down the problem to two instances, both relating to "resetting" the data source. Obviously there are workaround, but it might be helpful for other users facing the same problem to come across a thread at least acknowledging and discussing it. Here are the instances:

(1) When trying to Set Data Source from ArcCatalog, some layers change their data sources, but some don't. Here's a quick demo:

The following replacements work

DF1: LYR11 C:\Users\Marcel\Documents\ArcGIS\places.gdb to C:\Users\mm1100\Documents\ArcGIS\places.gdb

DF1: LYR12 C:\Users\Marcel\Documents\ArcGIS\places.gdb to C:\Users\mm1100\Documents\ArcGIS\places.gdb

DF1: LYR13 C:\Users\Marcel\Documents\ArcGIS\places.gdb to C:\Users\mm1100\Documents\ArcGIS\places.gdb

...

The Following replacements don't

DF2: LYR21 C:\Users\Marcel\Documents\ArcGIS\Packages\db21.gdb to C:\Users\mm1100\Documents\ArcGIS\unified.gdb

DF2: LYR22 C:\Users\Marcel\Documents\ArcGIS\Packages\db22.gdb to C:\Users\mm1100\Documents\ArcGIS\unified.gdb

DF2: LYR23 C:\Users\Marcel\Documents\ArcGIS\Packages\db23.gdb to C:\Users\mm1100\Documents\ArcGIS\unified.gdb

(2) When trying to change the source by calling the replaceDataSource then saveAsCopy functions, the data source for every layer in every data frame does in fact change, but does not display because its corresponding attribute table is empty! When data is added manually by clicking Add Data and choosing the intended data, you get a duplicate layer in your data frame that actually displays, because its attribute table is not empty.

I hope my description highlights the problem now.

RebeccaStrauch__GISP
MVP Emeritus

Marcel, so it looks like changing the name of the .gdb is the issue.  That all makes sense if you look at the help Updating and fixing data sources with arcpy.mapping—Help | ArcGIS for Desktop

  • findAndReplaceWorkspacePath or findAndReplaceWorkspacePaths allows you to substitute an entire or partial string for a layer or table's workspace path. It can't be used if the workspace type or dataset name has changed. It is ideal for scenarios where drive letters change, switch to UNC paths, update SDE connection file information, and so on. See the Common Scenarios section below.

i went thru quite a few tests to before it was able to get all my sources to change in my addin, and one thing I found is, even if your save doesn't give an error, if it isn't just perfect (i.e. Correct replacement) the save doesn't work.   I use several different methods to get the various paths to change. So, what you are seeing us "as design", for better or worse.

MarcelAfif
New Contributor III

Thank you, so it's a design thing by Esri then...

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

for the  "findAndReplaceWorkspacePath or findAndReplaceWorkspacePaths" yes, but there are other options, which is why I created the addin tool.  Each type and each change needs to be handled a little different.  I can't even say that I have all possible options figure out yet....but getting close (although not working on it at the moment).  But you can replace the .addin extension with .zip and look at any/all of my python scripts if you want to see some of the the ways I was updating paths.