I need to find the number of pixels of raster 1 that fall within different pixel values of raster 2. For example, there are 250 pixels of value=2 in raster1 that in value=89 of raster 2. Hence, I am using crosstab() from the raster package.
Now I need to find the cross tab of pixel count from the two rasters, within polygons in a shapefile. How do I do that?
One can think of this problem as- area (pixel count* pixel size) of opportunity (0-no opportunity, 1-opportunity specified in pixels in raster 1) in different categories of standards of living (1- low standard of living, 2-medium, 3-high specified in pixels in raster 2), across different US counties/states (polygons in shapefile).