Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reclassify a raster tif to unique values

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading