AnsweredAssumed Answered

Arcpy.describe with single print if all rasters have the same property

Question asked by r.brso on Nov 6, 2018
Latest reply on Nov 6, 2018 by Dan_Patterson

Hi all! I'm a master student in Geospatial Technologies and I'm just learning how to use arcpy and scripting. It's my 1st post so sorry for any mistake. My issue is: I have a bunch of rasters with different file formats in a folder (most of them are GRID). Using describe of arcpy, I want my script to inform the following: when all rasters have the same format, inform once the file format e.g print "All the rasters has the XXX format", but when there are different formats, list the formats of each raster. I'm very new to scripting so by now the code I wrote print all the files with their format. How can I do that? The code block is:


# Describing rasters file extension
for dirpath, dirnames, filenames in arcpy.da.Walk(inp_ws, datatype="RasterDataset"):
     dir_lu = [d for d in dirnames if d == 'lu']     
     dirnames = dir_lu
     for f in filenames:
          path = os.path.join(dirpath, f) # combine the current directory path and file name to create full path
          ext = arcpy.Describe(path).format
          print  "< {0} > for {1}".format(ext, f)


Thank you and, again, sorry for any mistake!