I have a land use classification raster file and a grided (5 km² grids) shapefile of my study region. I want to compute a landscape complexity index (LC) which can be computed by: LC = number of classes / number of pixels of dominant class.
I could compute the number of classes per grid with zonal statistics, but I am struggling with the calculation of the number of pixels of the dominant class per grid. How can that be accomplished?