title: How to write a raster file with our color palette on hard drive?
body: <p>I have a Raster file (its name: My_Gray_Scale_Raster.tif ). Here is the Tiff file download link:</p>
  
  <p><a href="https://www.dropbox.com/s/i2xig52flkr5bc6/My_Gray_Scale_Raster.tif?dl=1" rel="nofollow noreferrer">https://www.dropbox.com/s/i2xig52flkr5bc6/My_Gray_Scale_Raster.tif?dl=1</a></p>
  
  <p>using this R script I can read it in R:</p>
  
  <pre><code>setwd("F:/back19")
  list_tiff &lt;- raster(list.files(getwd(), pattern = "My_Gray_Scale_Raster.tif$", recursive = TRUE))
  list_tiff
  </code></pre>
  
  <p>So, I can see it has 7 values: 0 , 1 , 2 , 3 , 4 , 5 , and 6. </p>
  
  <pre><code>class       : RasterLayer 
  dimensions  : 420, 275, 115500  (nrow, ncol, ncell)
  resolution  : 500, 500  (x, y)
  extent      : 422447.3, 559947.3, 6029253, 6239253  (xmin, xmax, ymin, ymax)
  coord. ref. : +proj=utm +zone=12 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
  data source : F:/back19/My_Gray_Scale_Raster.tif 
  names       : My_Gray_Scale_Raster 
  values      : 0, 6  (min, max)
  </code></pre>
  
  <p>I want to assign 7 colors to each of these values, like: </p>
  
  <pre><code>my_clo &lt;- c("#009a1d" , "#3934ff" , "#faff34" ,  "#e62c00",  "#9f34ff", "#ff9f34", "#34ffd2" )
  </code></pre>
  
  <p>And finally, write/create a new Raster file on hard drive WITH my color palette. So, if anyone opens the new Raster file in ArcGIS, he/she sees the Raster file in my desired color palette.</p>
  
  <p>I googled and read many things on the net, but all of them were talking about Plot() the Raster inside R, rather than save a new Raster file with the color palette. </p>
  
  <p>Any comments would be highly appreciated.</p>