AnsweredAssumed Answered

Input parameter - ListRasters

Question asked by cpyywhite on Apr 5, 2018
Latest reply on Apr 6, 2018 by cpyywhite

I am pretty new to python and have come across a problem that I am not understanding how to get around.

I am building a custom tool in ArcMap and it has an input form. On that form, one of the parameters is a multivalue list of rasters.

My python script is receiving that input parameter:

      inRasterB = arcpy.GetParameterAsText(3).split(';')

without any problems. I get a perfect, comma-delimited list.

 

However, I need to loop through each of these individual rasters the user has provided. I originally had it setup with a ListRasters(inRasterB), but when I started getting results for every raster in my geodatabase, I realized that this isn't going to work because the list is being used as the wildcard, which obviously isn't going to match.

I tried changing my loop to iterate through the input directly:

    #rasters = sorted(arcpy.ListRasters(inRasterB)) #original code
    #for raster in rasters: #original code
    for raster in inRasterB: #new code

 

But now, it isn't recognizing those inputs as a list of rasters, but rather just a list of files (and can't find them on the filesystem due to the way geodatabases contain the rasters).

 

So........any thoughts on how I can go about getting a specific list of rasters from the user and looping through those rasters, and only those rasters, rather than every raster in the directory/gdb?

Outcomes