Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 ?

enter image description here

Update 1/13/2012

After I posted yesterday I found a geoprocessing tool to do this:

Repair Raster Catalog Paths (Data Management)

enter image description here

...And to see what the paths change to after this tool runs:

Export Raster Catalog Paths (Data Management)

enter image description here

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 repairRasterCatalogPaths_management function.

It would be nice if the original path and new path parameters accepted regular expressions... I'll give this a try next...

Any recommendations?

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()
share|improve this question
1  
Note that it is the raster catalog that is unmanaged, not the File GDB. –  valveLondon Jan 13 '12 at 0:05
    
Try using repair raster catalog paths. This might solve your problems. Thanks –  Ramakrishna Billakanti Jan 13 '12 at 23:32
add comment

3 Answers

up vote 2 down vote accepted

Based on your edit to your question, it looks like you need to parse out parts of the old path to build the new path. How about splitting up the old path into a list, then building the new path with parts of that list:

>>> import os
>>> old_path = "\\dgdbimg\EGD\Data\DTED_2"
>>> old_parts = old_path.split("\\")
>>> old_parts
['', 'dgdbimg', 'EGD', 'Data', 'DTED_2']
>>> new_path = os.path.join("C:\WorkSpace\Andy3", old_parts[3], old_parts[4])
>>> new_path
'C:\\WorkSpace\\Andy3\\Data\\DTED_2'
>>>

EDIT:

Have a meeting in a few minutes so quickly - here's what I'd do. Either manually push the dbf to a file geodatabase table or do it with code, then loop through the records of the table, and for each one use the parts to build the new path, then call the Repair Raster Catalogs Paths tool. Some psuedo-code:

push dbf to FGDB table (may be a tool to do this? or just do it manually in ArcCatalog)
loop through records in table
    parse out old paths parts
    build new path
    repairRasterCatalogPaths_management()

Here is real (untested) code to try:

import arcpy
import os

arcpy.env.overwriteOutput = 1
arcpy.TableToTable_conversion("C:/Temp/CatalogPaths.dbf", "D:/target.gdb", "DbfToTable")

rows = arcpy.SearchCursor("D:/target.gdb/DbfToTable")
for row in rows:
    old_path = str(row.getValue("Old_Path_Field"))
    old_parts = old_path.split("\\")
    new_path = os.path.join("C:\WorkSpace\Andy3", old_parts[3], old_parts[4])
    arcpy.RepairRasterCatalogPaths_management("RepairRC.gdb\\Unmanaged", "FIX", old_path, new_path)
share|improve this answer
    
Thanks Chad. I think I'll be ok doing the string manipulation part once I have the original path string. I'd like to know how to get the original paths programmatically one by one from the raster catalog so I can manipulate them. I'd like to loop through, reading each original path, perform the path conversion and then call repairRasterCatalogPaths_management with the new path. The exportrastercatalogpaths_management only outputs to a DBF file but I'm not sure what function can read this. –  Andy Arismendi Jan 13 '12 at 15:30
    
@AndyArismendi - see my edit, give that a go. –  Chad Cooper Jan 13 '12 at 17:48
    
Thanks :-) I found a way to read the DBF directly: [1] rows = gp.SearchCursor(r"C:\Output.dbf") [2] row = rows.Next() [3] path = row.GetValue("Path"). Looks like TableToTable_conversion isn't needed. –  Andy Arismendi Jan 13 '12 at 18:40
    
@AndyArismendi - D'OH! Totally forgot the SearchCursor would read a dbf! –  Chad Cooper Jan 13 '12 at 22:22
    
You have it pretty much right so I accepted your answer. I updated my post with my final working script. –  Andy Arismendi Jan 13 '12 at 22:46
add comment

Have you tried Repair Raster Catalog Path? In Python:

# Create the geoprocessing object
import arcgisscripting
gp = arcgisscripting.create()

gp.repairRasterCatalogPaths_management(r"\\temp\fgdb.gdb\airphoto", "FIX" , "*", r"\\temp\source")
share|improve this answer
    
Yea I found this yesterday after I posted and started to try it out... There is a toolbox with a GUI for it too under ArcToolbox>Data Management Tools>Raster>Raster Catalog>Repair Raster Catalog Paths. However i'm having a problem getting it to work for me. –  Andy Arismendi Jan 13 '12 at 13:49
add comment

Using the Repair Raster Catalog Paths tool from the Toolbox will tell you that the Original path is invalid. Instead use the Python command window in ArcCatalog or ArcMap. Don't use "" is you want to change the path for instance original images are at e:\data and want to change to f:\data. Using the an "" will cause the tool to append the image new path name plus the image name rather than just substituting the new path.

arcpy.RepairRasterCatalogPaths_management(r'F:\data\Imagery_1930c\ImgCat1930c.gdb\ImgCat1930c2',"FIX",r'E:\data\Imagery_1930c',r'F:\data\Imagery_1930c')

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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