Hello
Here is a simple script that places rasters into a catalog then mosaics them. I can't help but feel I am doing this in a less than optimal manner. So, I am wondering if there is a faster way to run this or if I should just be patient with current speeds? Thanks for any help and suggestions!
import arcpy
from arcpy import env
ws = r"C:/test"
rc = r"C:/H/H.gdb/DEM_Tiles"
try:
for dirpath, dirnames, filenames in arcpy.da.Walk(ws, datatype="RasterDataset", type="ALL"):
for filename in filenames:
addRaster = arcpy.WorkspaceToRasterCatalog_management(ws, rc, "INCLUDE_SUBDIRECTORIES", "NONE")
print "adding:", filename
except:
print "Workspace to raster catalog failed"
print arcpy.GetMessages()
try:
print "Setting up mosaic for tiles..."
arcpy.RasterCatalogToRasterDataset_management(r"C:H.gdb/DEM_Tiles", r"C:/H.gdb/Mosaic", "", "FIRST", "FIRST", "", "", "8_BIT_UNSIGNED", "NONE", "NONE", "", "")
except:
print "raster mosaic failed"
print arcpy.GetMessages()
Solved! Go to Solution.
Yes, and it's 100x faster! You can apply functions to mosaic datasets by right-clicking on the mosaic dataset in the catalog window > Properties > Functions tab. Below are some helpful links:
Hi Chris,
Did you create a managed raster catalog, or an unmanaged raster catalog? A managed raster catalog will copy the rasters into the geodatabase, while an unmanaged raster catalog will simply reference the path of the rasters on disk.
I wouldn't recommend using a raster catalog at all, though. I would recommend creating a mosaic dataset. The performance is very fast, and I doubt you'll have the need to export the mosaic dataset to a raster dataset.
Jake: Thank you for the response. I saw the mosaic dataset option but was unsure of my ability to use a clip function with it. Will I still be able to clip boundaries out of a mosaic dataset? I'll have to run this and give it a shot.
Thanks
Chris
Yes, and it's 100x faster! You can apply functions to mosaic datasets by right-clicking on the mosaic dataset in the catalog window > Properties > Functions tab. Below are some helpful links:
Amazing, thank you for opening my eyes to this!