Nested conditional statement in ArcGIS on multiple rasters

المشرف العام

Administrator
طاقم الإدارة
I have a list of rasters in ArcGIS and I want to create a conditional (Con) nested statement based on all the rasters of the list. I want this to be reiterate through many lists (the number of rasters in the lists can change). So far, I found a non-elegant way which build a string and then pass the string to the exec function, but I read the use of exec is higly discouraged. Any clever way to do it?

listRst = arcpy.ListRasters("*", "TIF")initString = "outCon = "for rst in listRst: rstString = " Con(( Raster(\"" + rst + "\") > 0) & ( Raster(\"" + rst + "\") < 367), 1," initString = initString + rstStringconString = initString + " 0" + ")"*len(listRst)exec (conString)outCon.Save("ConTest.tif")

أكثر...
 
أعلى