I fitted a species distribution model and predicted the suitable habitat using this model, and then I got a map plotted in R.
I tried to save this prediction as a raster, using code:
rf<-writeRaster(px, filename="predict.tif", format="GTiff")
However, I could only export a tif format file without an attribute table. I could put this raster to ArcGIS software, but without an attribute table, it is difficult to run any analysis.
How can I export a raster with it's attribute table in R?
ratify
function and things likeas.factor
might be what you want if you have a categorical raster and want to save labels for each class.