|
POST
|
Jake: Besides a Mosaic Dataset, what do you think would be the best way to store raster images outside of SDE to get excellent performance in ArcMap, where I would be able to use the replaceDataSource in python to get an automated solution that can be performed during non-business hours? In response to your last post, many of the the current SDE image layers can be found in group layers and not necessarily at the bottom of the TOC, so your approach would by no means be the universal solution for my organization. In the past I had resourced these same images from IMS to SDE using a programmatic approach in VBA, but group layers also presented a problem. I had to resource these layers manually after getting an inventory of how often this occurred on my network. I was hoping the replaceDataSource in python for ArcMap v10.0 would make this task easier, but it appears that this option was not accounted for at this point in python.
... View more
02-13-2012
09:42 AM
|
0
|
0
|
859
|
|
POST
|
Jake: Do you know if it will be a capability of python scripting in ArcGIS v10.1 to convert SDE raster images to a mosaic dataset? I would need to perform this task on 10s of thousands of layers so a manual approach is extremely impractical. Thanks.
... View more
02-13-2012
09:11 AM
|
0
|
0
|
859
|
|
POST
|
Jake: In the original post, the posting person was trying to convert rasters from one SDE database to another. In your response, you said it would be better to use a mosaic dataset to store the raster data. As such, I would want to convert raster data from SDE to a mosaic dataset for layers that I have saved in many mxds. I thought you were indicating that this can be done, but your last post said this is not possible with replaceDataSource. Is there any other python method that could be used to make this conversion? Your feedback is greatly appreciated. Thanks.
... View more
02-13-2012
08:24 AM
|
0
|
0
|
859
|
|
POST
|
Jake: What would be the replaceDataSource syntax if one was converting from a raster in SDE to a mosaic dataset in a file geodatabase? This is the syntax I am using, which follows the ArcGIS Help, but I am getting an error message:
elif layr.datasetName == "ORTHO2005.ORTHOS2005":
print("The dataset name in Resource_mxd is " + layr.datasetName)
layr.replaceDataSource(r"\\gis\GIS\Work\arcmap\mosaic_2010.gdb", "FILEGDB_WORKSPACE", "orthos_2010")
In this code, "orthos_2010" is the mosaic dataset that contains 2010 Orthophotos. I am not specifying where the data originates in SDE, other than making sure that the focus layer to be converted has a datasetName = ORTHO2005.ORTHOS2005, as I did not need to do this for vector datasets that I resourced from SDE to a file geodatabase. Your assistance is greatly appreciated. Thanks.
... View more
02-13-2012
07:37 AM
|
0
|
0
|
1828
|
|
POST
|
Hi Christina: In your python script, maybe you can use the datasetname to get the full name of the SDE feature class so it differentiates between BULLITT.bg and PTD.bg. You can then use If Then statements to make sure it gets resourced to the correct data. In addition, do you plan on running this script on many mxds at once in a loop? I have been writing similar python scripts where I resource SDE data and it appears there is a memory leak as the memory usage for the script keeps going up until it locks up the computer. I am currently working with ESRI Technical Support to resolve this particular issue. Please let me know if you need any clarification or additional information from my response. Thank you.
... View more
02-13-2012
05:21 AM
|
0
|
0
|
1849
|
|
POST
|
Chris: I tried your approach to set lyrs equal to a variable and then delete the lyrs variable after using it in each mxd, but it did not help the memory issue. I also tried to delete the servProp variable and that did not help the memory issue either.
... View more
02-08-2012
10:22 AM
|
0
|
0
|
965
|
|
POST
|
Murray: I have had to deal with this problem in the past (used VBA which is going away) and I will need to deal with it again in the future which I am using python to automate the process. If you can provide a more detailed picture of your situation, I could provide a starter script that you could test to update your file paths. Where does the data originate from (e.g. shapefiles, personal geodatabases, file geodatabases)? Very important, what version of ArcView (ArcGIS Desktop) are you using? Python in version 10 has a good deal more built-in functionality to get this job done.
... View more
02-08-2012
08:35 AM
|
0
|
0
|
290
|
|
POST
|
Thanks Chris. The script with the subprocess did exactly what you said it would and flooded the processor with parallel processes. Here is my code with just one python script where the memory usage keeps increasing until the python scripts freezes up. The script is meant to loop through a selected directory, get the mxds and resource the SDE layers from the original SDE connection to a different SDE connection. You can open up Task Manager while running this script and see how memory usage for the pythonw.exe process keeps increasing. Please note that you will need to run this script on a directory with a good number of mxd files that have many SDE layers in order to see the performance hit.
import os, sys, string, arcpy
mxd_match = ".mxd"
Directory_Search = r"\\server00\e$\restore5\Experiment\Test_10"
new_connPrefix = r"C:\Documents and Settings\Application Data\ESRI\Desktop10.0\ArcCatalog"
def Conn_Info(usr):
if usr == "user01":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
return new_connection
elif usr == "user02":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@development.sde"
return new_connection
elif usr == "user03":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
return new_connection
del new_connection
for root, dirs, files in os.walk(Directory_Search):
# for root, dirs, files in os.walk(arcpy.GetParameterAsText(0)):
fListLength = len(files)
if (fListLength != 0):
n = 0
for f in files:
full_path = root + "\\" + str(f)
if f.endswith(mxd_match):
mxd = arcpy.mapping.MapDocument(full_path)
for lyr in arcpy.mapping.ListLayers(mxd):
try:
if lyr.supports("DATASOURCE"):
if lyr.supports("SERVICEPROPERTIES"):
servProp = lyr.serviceProperties
user = str(servProp.get('UserName', 'N/A'))
new_conn = Conn_Info(user)
lyr.replaceDataSource(new_conn, "SDE_WORKSPACE", lyr.datasetName)
except:
print arcpy.GetMessages(2)
del lyr
try:
# mxd.saveACopy(root + "\\" + f[:-4] + "_New.mxd", "9.3")
mxd.save()
except:
print arcpy.GetMessages(2)
del mxd
del full_path
Thanks for all your help!!
... View more
02-08-2012
08:27 AM
|
0
|
0
|
965
|
|
POST
|
Chris: Why do I need to worry about the number of subprocesses? I wrote my main python script to loop through a directory, its subdirectories and files looking for mxds. Then I call the subprocess python script for the file that has focus and I manipulate that mxd. Once that is done and the mxd gets saved, I thought the code goes back to the main python script and releases the subprocess python script from memory. Then I loop to the next mxd and call the subprocess python script again. The reason I went this route in the first place was due to memory usage always climbing while looping through a directory until the python script just hung. Could it be that I just needed to release additional items from temporary memory when I was just using one script to obtain the results? Thanks.
... View more
02-07-2012
01:26 PM
|
0
|
0
|
965
|
|
POST
|
Thanks Chris That was the syntax that was needed to call the subprocess python script in Windows. I could not find any other examples of that syntax when searching the web.
... View more
02-07-2012
11:33 AM
|
0
|
0
|
965
|
|
POST
|
Chris: Here's the code I am trying to run to call a subprocess to actually modify properties of mxd files:
import os, sys, string, arcpy
import subprocess
mxd_match = ".mxd"
fileErrList = []
procs = []
Directory_Search = r"\\tgapparc00\e$\restore5\Planning_Run\Broken_Links\Test"
for root, dirs, files in os.walk(Directory_Search):
fListLength = len(files)
if (fListLength != 0):
n = 0
for f in files:
if f.endswith(mxd_match):
full_path = root + "\\" + str(f)
cmd = "'C:\Python26\ArcGIS10.0\python.exe \\\\tgapparc01\\c$\\ReplaceSource.py' full_path"
proc = subprocess.Popen(cmd,shell=True)
procs.append(proc)
... View more
02-07-2012
10:39 AM
|
0
|
0
|
2930
|
|
POST
|
Chris: I did see your last response and I moved the python script, that is called, to a folder with no spaces. No matter how I format the cmd line, the subprocess never gets executed.
... View more
02-07-2012
10:29 AM
|
0
|
0
|
2930
|
|
POST
|
Chris: Can you please be a little bit more specific in what your code is looking for with the cmd = "python foo.py arg1 arg2" line? I still cannot get my code to evaluate the subprocess python script. Does python refer to python.exe that has been installed on the computer that you are running this script from (e.g. c:\Python26\ArcGIS10.0\python.exe)? Does foo.py refer tp the python script that you are running in the subprocess? If so, wouldn't you need to specify the full path to this file? Are arg1 and arg2 variables from the primary script that you are sending to the subprocess script? If so, what is the syntax to get the subprocess script to accept these arguments? I ask because I am using arcpy.GetParameterAsText(0) to evaluate the single argument that I am trying to pass. Your assistance is greatly appreciated. Thanks.
... View more
02-07-2012
10:03 AM
|
0
|
0
|
2930
|
|
POST
|
I believe as long as the new connection that you created in ArcCatalog has the direct connection parameters specified, the source should then be changed to a direct connection.
... View more
02-07-2012
09:56 AM
|
0
|
0
|
819
|
|
POST
|
Chris: I tried running the first portion of your code, but the subprocess is not executing. Here is my syntax to call the subprocess script: cmd = "C:\\Python26\\ArcGIS10.0\\python.exe \\\\tgapparc01\\c$\\GIS Testing\\ReplaceSource.py full_path" In the cmd line, full_path is the file that has the focus. File is stored in the full_path variable. In the ReplaceSource.py script, I am trying to use the arcpy.GetParameterAsText(0) to bring in this argument. I'm not sure if this is the problem? Could this issue possibly be how I am calling out the python executable and the python script that gets run in the subprocess? Your assistance is greatly appreciated. Thanks.
... View more
02-07-2012
08:29 AM
|
0
|
0
|
2930
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-26-2025 06:10 AM | |
| 1 | 09-04-2025 02:19 PM | |
| 1 | 08-29-2025 08:29 AM | |
| 1 | 08-21-2025 12:45 PM | |
| 1 | 07-25-2025 09:09 AM |
| Online Status |
Online
|
| Date Last Visited |
yesterday
|