I have a raster with integer values graded from 0 to 32. I also have a shapefile of this area subdivided into three basins A, B and C.
I would like to calculate the area (or the number of pixels, then transform it to area) of each raster class based on the shapefile. For example, for Basin "A", what is the area (or number of pixels) with a value of 0? and with a value of 1? and with value 2......?
I don't have a script for that, but I have here what would be the initial to load the files in R.
library(sf) library(stars) library(maptools) rastermap<-read_stars('C:/0mestrado/SRTM_SAGA/duvida/raster_2005_UTM_cut.tif') shapefilemap<-readShapePoly('C:/0mestrado/SRTM_SAGA/duvida/01vetor_UTM.shp')