I would like to iterate a list of raster objects and apply Con()
to each raster. The rasters are in a specific order in the list. That's important. All I want to do is to write the value of the current raster in the cell if there is no value in the base_raster cell already! Only 1 raster will ever write to a cell. The first raster (following order in the list) that has a value > 0 can write to the cell, and that cell must not be overwritten by the following raster.
base_raster = list_raster_obj[0]
for raster in list_raster_obj[1:]:
#if base_raster has already a value in that cell, do nothing
raster_out = Con(base_raster < 1, raster, base_raster)
base_raster = raster_out
raster_out.save(path)
This kind of works for 3,4 rasters but takes ages if you get a list with like 10 rasters. If you know the amount of raster you want to compare and "hardcode" the Con()
commands, it is blazing fast - like in ArcGIS Pro. It is only extremely slow when you use arcpy with a list.
What am I doing wrong or missing here?
Edit: I need also to have an attribute table in the final raster.