opt2 = Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "blank",-9999, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "CottonLB" ,1, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "FodderLB" ,2, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "FruitsLB" ,3, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "GroundnutLB" ,4, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "JatrophaLB" ,5, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "MaizeLB" ,6, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "MilletLB" ,7, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "MiscanthusLB" ,8, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "NarcostimulantsLB" ,9, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "OilpalmLB" ,10, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "PulsesLB" ,11, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "RapeseedLB" ,12, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "RiceLB" ,13, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "RootsLB" ,14, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SorghumLB" ,15, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SoybeanLB" ,16, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SugarbeetLB" ,17, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SugarcaneLB" ,18, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SunflowerLB" ,19, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "SwitchgrassLB" ,20, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "TubersLB" ,21, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "VegetablesLB" ,22, Con(CellStatistics(["CottonLB","FodderLB","FruitsLB","GroundnutLB","JatrophaLB","MaizeLB","MilletLB","MiscanthusLB","NarcostimulantsLB","OilpalmLB","PulsesLB","RapeseedLB","RiceLB","RootsLB","SorghumLB","SoybeanLB","SugarbeetLB","SugarcaneLB","SunflowerLB","SwitchgrassLB","TubersLB","VegetablesLB","WheatLB","blank"],"MAXIMUM","DATA") == "WheatLB" ,23,-9999))))))))))))))))))))))))
Solved! Go to Solution.
Use the HighestPosition function/tool. Used to be called UPos in earlier versions.
Thanks lpinner, this was spot-on! In theory it is doing what I need, however in practice it's not working out exactly as planned. I have a follow up question I'm hoping I can get some help with:
...
Much appreciated!
Running the tool with three or more input datasets seems to include only results that are an intersection of all the inputs. All other non-intersecting areas are NoData. What I would like is to have a dataset represented in the results, even if it is the only one with a value in a specific cell.
HighestPosition(Con(IsNull(raster1), -999, raster1), Con(IsNull(raster2), -999, raster2), Con(IsNull(raster3), -999, raster3))
Did you check that HighestPosition (or Upos) function works well or not?
I never use this function, but it seems the illustration from ESRI book is not correct - the return is not always the cell with Max value. ig: the downside left conner cell values from input raster datasets are 4, 3, 1, but the return value for this cell is 1.
But the illustration for Max (9 version) function is correct - this cell return value is 4.
It's working as expected. The default processing extent is the intersection of input extents, change this to union - see the help for more info. However, any cell with NoData will be NoData in the output. So change it to a low number first.
i.e. in the raster calculator:HighestPosition(Con(IsNull(raster1), -999, raster1), Con(IsNull(raster2), -999, raster2), Con(IsNull(raster3), -999, raster3))
No, the return value of 1 is correct. HighestPosition/Upos returns the position of the raster with the highest value in the list, not the maximum value itself.
For your example of 4, 3, 1, 4 is the max and it is at position 1. For something like 9, 12, 7, the HighestPosition/Upos value would be 2 as the raster with the highest value is at the 2nd position in the list.
If the output of the HighestPosition is the number of raster dataset, this function is not suitable for Jproville's purpose, its return is still to be replaced by the ralated dataset cell original value, and to eliminate the "NoData " output value.
...one thing I'd like to see is a raster showing me which of the 23 layers contained the maximum value that was chosen.
The Max function is fit this application, but why ESRI removed this tool in the 10 version?
I tried a great deal of variations on it, but I continue to be baffled by the fact that I only keep getting the intersection of the inputs rather than the union.
Con(IsNull(raster), -999, raster)
Are you saying the output extent is wrong (this is what the environment controls) or just the particular cells are only getting a value if all the inputs from the stack are data cells? If the latter, Luke's suggestion,Con(IsNull(raster), -999, raster)
should work.