I'm using ArcGIS 9.3.1 and I have an unmanaged file geodatabase with raster catalogs in it. Tiles are loaded inside the catalog and each tile has a "Full Path" property which is environment specific. Are there any examples around that show how to batch update the path property perhaps using the Python arcgisscripting API or some tool already built in to ArcGIS ?
After I posted yesterday I found a geoprocessing tool to do this:
...And to see what the paths change to after this tool runs:
This outputs a .DBF file that can be viewed in ArcCatalog.
The problem is that my raster catalog paths are different, for example:
\\dgdbimg\EGD\Data\DTED_2\e041\n32.dt2 \\dgdbimg\EGD\Data\DTED_2\e041\n33.dt2 \\dgdbimg\EGD\Data\DTED_2\e042\n32.dt2 \\dgdbimg\EGD\Data\DTED_2\e042\n33.dt2
After running this tools with
* it changes every path to whatever is specified as the new path:
C:\WorkSpace\Andy3\NgaRaster.gdb\DTED_2 C:\WorkSpace\Andy3\NgaRaster.gdb\DTED_2 C:\WorkSpace\Andy3\NgaRaster.gdb\DTED_2 C:\WorkSpace\Andy3\NgaRaster.gdb\DTED_2
I'm trying to find a way to just change the parent folder path like this:
"\\dgdbimg\EGD\Data\DTED_2" --> "C:\WorkSpace\Andy3\Data\DTED_2"
I'm might have to write some more intricate python to get the current path and do my own string manipulation in order to pass in the needed replacement path to the
It would be nice if the
original path and
new path parameters accepted regular expressions... I'll give this a try next...
Update 2 1/13/2012 - Final Solution
import arcgisscripting import os.path gp = arcgisscripting.create() rasterCatalogPath = r"C:\WorkSpace\Andy\NgaRaster.gdb\DTED_2" oldBasePath = r"\\server\share\Data" newBasePath = r"C:\WorkSpace\Andy\Data" dbfPath = r"C:\BrokenPath.dbf" dbfXmlPath = dbfPath + ".xml" if os.path.exists(dbfPath): os.remove(dbfPath) if os.path.exists(dbfXmlPath): os.remove(dbfXmlPath) result = gp.exportrastercatalogpaths_management( rasterCatalogPath, "BROKEN", dbfPath) rows = gp.SearchCursor(dbfPath) row = rows.Next() while row: path = row.GetValue("Path") fileParentPath = os.path.dirname(path) newPath = fileParentPath.replace(oldBasePath, newBasePath) gp.repairRasterCatalogPaths_management( rasterCatalogPath, "FIX", fileParentPath, newPath) row = rows.Next()