Faster way to automate this?

1727
4
Jump to solution
09-30-2014 01:33 PM
ChrisBrannin1
New Contributor

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()

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

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:

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

View solution in original post

4 Replies
JakeSkinner
Esri Esteemed Contributor

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.

0 Kudos
ChrisBrannin1
New Contributor

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

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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:

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

ChrisBrannin1
New Contributor

Amazing, thank you for opening my eyes to this!

0 Kudos