I have a raster tif file with unique values: 0,2,4,5,9,111,114,115,116,124,125,126.
I need to reclassify my raster cell values to be:
0,2,4,5,9,4,4,4,4,4,4,4.
I used the following codes:
is<-c(0,2,4,5,9,111,114,115,116,124,125,126)
become<-c(0,2,4,5,9,4,4,4,4,4,4,4)
recMat<-matrix(c(is,become),ncol=2,nrow=12)
LU_AOI_2 <- reclassify(LU_AOI, recMat)# Reclassify
After the reclassification is done, when I plot my raster, I still see floating values. I need a raster with those unique values(0,2,4,5,9,4,4,4,4,4,4,4) only.
What is wrong with my codes? Why can I not make a raster with unique integer values?
Please help me.
Thanks
>Solution :
What happens if you try to specify the dtype as an unsigned 1-byte integer?
LU_AOI_2 <- reclassify(LU_AOI, recMat, dtype='INT1U')