Select to view content in your preferred language

mapDoc.save() fails after mapDoc.replaceWorkspaces() in MXD with ArcGIS Image Service

1940
12
01-16-2014 07:48 AM
CarlBeyerhelm
Frequent Contributor
Our organization is migrating from SDE 9.3.1 to SDE 10.1 which entails new SDE connection files.

I've developed a script tool that walks a directory tree looking for MXD files that have an old SDE connection, and then replaces the old SDE connection(s) with the new SDE connection(s) using the .replaceWorkspaces() method.

The script works totally as expeted except for MXDs that contain an ArcGIS Image Service raster layer.  In these situations, the SDE connection to the vector data is successfully replaced but, somehow, that process strips all of the properties from the Image Service layers!

In the attached image below, notice that the SDE connection has been updated to gdb01a as it should, but the Image Service layers are stripped of their source properties.  That causes the MXD to be un-savable when I apply the .save() method.

This seems quite bizarre to me.  Any explanations or remedies would be appreciated.  Thank you...

[ATTACH=CONFIG]30573[/ATTACH]
Tags (2)
0 Kudos
12 Replies
JeffBarrette
Esri Regular Contributor
Can you please open an incident with technical support so we can evaluate the situtation.

Jeff
0 Kudos
CarlBeyerhelm
Frequent Contributor
I'd be happy to but, I have to confess, I'm not sure how to do that.

Can you point me in the right direction, please?

Thanks...
0 Kudos
JeffBarrette
Esri Regular Contributor
Go to:

http://support.esri.com/en/

Then you have an option to contact via email or by phone.

Jeff
0 Kudos
JoshuaBixby
MVP Esteemed Contributor
Incident has been created with Esri Support with the same subject/name as this forum posting.
0 Kudos
CarlBeyerhelm
Frequent Contributor
For reference, the incident ID is:

Esri Incident #1234321 (Thomas J) mapDoc.save() fails after mapDoc.replaceWorkspaces() in MXD with ArcGIS Image Service
0 Kudos
MichaelVolz
Esteemed Contributor
How about trying to use the UpdateLayer method on your ArcGIS Image Service layers?  You could pre-process the ArcGIS Image Service lyr files for your upgraded environment and then run this method using these new lyr files to replace the old layers.  This is how I accomplished something similar to you where I had to convert image layers originating in SDE with raster mosaic datasets.  I found there to be no other conversion method that would work with this type of scenario.
0 Kudos
CarlBeyerhelm
Frequent Contributor
Your suggestion would be a good approach in a situation where we needed to update the Image Service layer sources.  In this situation, however, I only need to update the SDE connections to accommodate the upgraded SDE environment.  The Image Service environment is not changing, so there is no need or desire to update Image Server layers.

To illustrate this issue further, the 3 attached images document the step-by-step results at crucial points in the replaceWorkspaces() process using the ArcMap Python interactive window.

  1. The first image is from just after the layers have been interrogated for their workspacePath and a TOC refresh.  No signs of any trouble yet.  All is well.

  2. The second image is from just 2 commands later�?�the replaceWorkspaces() and the TOC refresh commands.  Here, the targeted SDE workspace has indeed been replaced successfully, but the replaceWorkspaces() method has also caused the non-target Image Sever Source properties to be deleted or corrupted.  Clearly, something in the replaceWorkspaces() method has stepped on the Image Server content even though replaceWorkspaces() did not pertain to any Image Service layers.

  3. The third image follows mapDoc.save(), and illustrates that the broken doc cannot be saved.


The bottom line is that replaceWorkspaces() successfully updates the intended target SDE connections, but it also has the unintended consequence of deleting or corrupting non-target Image Service source properties.

If I've missed your point, please reply back...
0 Kudos
MichaelVolz
Esteemed Contributor
Carl:

It seems as though you might have encountered a bug with the replaceWorkspaces() method and I would not be confident in a timely fix of a bug.  The replaceWorkspaces() method seems like a more universal resourcing method where all the data originates in the same database.  I had to resource data from multiple databases with multiple user connections to the databases. 

I would suggest using the replaceDataSource method where you could interrogate each connection and then build a new connection file (.sde).  If a new .sde connection file has already been built then just use the new .sde file (This is what I did).

I used the .sde file with replaceDataSource and I handled my imagery with the UpdateLayer method since I was no longer storing the imagery in SDE.

This would be a workaround to the errors you are getting with the replaceWorkspaces() method.
0 Kudos
CarlBeyerhelm
Frequent Contributor
Yes, the replaceDataSource() method does seem like the only ArcPy work-around at this point.

Thank you.
0 Kudos