Just a small question... do you need them as separated files or is merging them into a single raster an option before you apply the minus tool?
This is kind of similar approach that I am looking for. I have many pairs (2000+) of orthophotos from years 2011 and 2014. They are stored in 2 separate folders. I would also like to find differences between them, but first of all I need to reclassify only one band from orthophoto; orthophotos are composited of red, green and blue band. I need to reclassify only blue band in 2 classes, then subtract them and export result as polygon.
Orthophotos that overlapping each other have same name, except the 8th character is different.
I am attaching picture of model builder process for one set of orthophoto. Orthophotos with name E063462.tif and E063462A.tif are overlapping each other.
I am not familiar with python so I need help to write a code to automate this process with 2000+ orthophoto pairs.
import arcpy, os from arcpy import env arcpy.CheckOutExtension("Spatial") env.workspace = r"C:\temp\python\Rasters" list1 = [] lstRasters = arcpy.ListRasters("*") for raster in lstRasters: list1.append(env.workspace + os.sep + raster) env.workspace = r"C:\temp\python\Rasters2" list2 = [] lstRasters = arcpy.ListRasters("*") for raster in lstRasters: list2.append(env.workspace + os.sep + raster) count = len(list1) x = 0 while x < count: raster = list1 name = raster.split("\\")[-1] outMinus = arcpy.sa.Minus(list1, list2) outMinus.save(r"C:\temp\python\Output" + os.sep + name.split(".")[0] + "_minus.tif") print 'Successfully created raster' x += 1 del list1, list2, raster
import arcpy from arcpy import env env.workspace = r"C:\temp\python\Rasters" arcpy.CheckOutExtension("spatial") lstRasters = arcpy.ListRasters("*") for raster in lstRasters: outMinus = arcpy.sa.Minus(raster, r"C:\data\raster\TIFF\example1.tif") outMinus.save(r"C:\temp\python\Rasters" + "\\" + raster + "_minus.tif") print "Successfully subtracted raster"
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.