I am working with ArcGIS, but this should be applicable to any situation with an iterator and a string. I have pairs of images which I want to run through this function, which have the same name and then increasing numbers within parenthesis. I am trying to use an iterator which would update the number on each loop, so the process would run each loop on 2 different images.
Here is my code:
def my_filter(iterable):
result=[]
for i in iterable:
result.append(i)
if i==400:
continue
yield result
result=[]
idx = iter(range(0, 400))
for i in my_filter(idx):
arcpy.management.CompositeBands("'Visual ("[i]").tif';'Thermal ("[i]").tif'",
r"C:\Users\calma\Documents\ArcGIS\Projects\RasterMerge\RasterMerge.gdb\Multi"[i])
}
Essentially, is there a way for me to put the i
s in this string that would recognize it as a part of the string and get the correct photo?
Here is what it normally looks like:
arcpy.management.CompositeBands("'Visual (23).tif';'Thermal (23).tif'", r"C:\Users\calma\Documents\ArcGIS\Projects\RasterMerge\RasterMerge.gdb\Multi23")