I generate a raster map in R with some shaded portion, then i plot my shape file on the raster file to show boundaries of the map. I can calculate the the overall shaded area with a code but I want to calculate the shaded region coming under the separate polygons when i plot shape file on raster. Please help me with the code.
I am using maxent in R to have an idea of suitable area of certain crop for whole country. when I generate map, it is a raster file and I can calculate suitable area for whole country with a code, but I want to calculate the area for provinces as well for which i plot province vise shape file on the raster map.
I want help with the area calculation for each shaded polygon when i plot shape file on raster
pred_me2 [pred_me2 <=0.33] <- NA
pred_me2 [pred_me2 >0.66] <- NA
cell_size<-area (pred_me2, na.rm=TRUE, weights=FALSE)
cell_size<-cell_size[!is.na (cell_size)]
suitable<-length (cell_size)*median(cell_size)