12-19-2016 01:24 AM
I am working on a complex model. For further processing of my datasets I need to combine a class raster with zone vectors. The goal is to get three tables added to the vector that do contain the 3 most appearing class values for each zone.
The most appearing one is easy peasy: compute the zonal summary matrix and use this as input for zonal majority and add this table (after removing the background call row) as new attribute table to the feature dataset.
But how do I get the two next most appearing values? Any ideas?
Solved! Go to Solution.
12-20-2016 01:56 AM
Hiya. This is probably a terrible hack and there will be more elegant ways to do this, but the attached model takes the first zonal majority and then subtracts that value from the original classification leaving you with an output with which you can run another zonal majority to get the second most prevelant class. Repeat until you're happy! Cheers, Johnnie
12-20-2016 02:23 AM
first of all, thanks for digging into my problem and your suggestion. But your included model does more or less solve only the first step. It gets the zonal majortiy value for each zone. You find my solution for this attached in the zip.
But as I told you. This is the first step. Next step is: get the second often/frequent class for each zone. And than get the third frequent class for each zone. The class file has between 70 and 100 different values.
To sum it up: I need three attributes for each zone that tell me: the most frequent, the second frequent and the third frequent class.
So either I am able to get this out of the summary matrix or I need to do some masking iterations where I set the most frequent vaule in each zone to no data and then re-run the zonal majority calculation.
12-20-2016 02:26 AM
No, my model does more. It then takes that zonal majority, eliminates that value from the original classification and provides you with a new classification which you can run through zonal majority again to get the second most prevelent class. I didn't include that bit in the model as I was sure you'd be able to tack it on the end. Cheers, Johnnie
12-21-2016 01:19 AM
I think I have found a working solution. So if anybody is ever facing the same problem here comes my solution:
I am using the output table of the zonal majortiy operator to do a lookup with the zone raster. This will set all zone pixels to the zonal majortiy value of each zone. Next step is to set all class pixels in each zone that do have the same pixel value as the zonal majority pixels to 0. If I now re-run the zonal majortiy computation with the option to ignore all input pixels with the value of 0 I will endup with a table containing the second frequent pixel within each zone. Now I redo the step described above to retrieve the third frequent value!
Find my solution in the zip attached to this post.