<div dir="ltr">Hi Roger:<div><br></div><div>Not sure if I'm following what you are asking about -- ENVI classification files have four characteristics that differentiate themselves from "ENVI Standard" files, all of which are stored in the ENVI header:</div>


<div>file type = ENVI Classification <br></div><div>--> as opposed to "ENVI Standard"</div><div>and 3 class parameters relating to 1) the number of classes, 2) the class colors in RGB format, and 3) the class names.</div>

<div><br></div><div>I'm attaching two small example files to this email, one is a "raw" file (test_envi_noclass.envi + .hdr) generated from a writeRaster(...,.format="ENVI",datatype="INT2S",NAflag=0); and one is what the file should look like, given the variables below (test_envi_class.envi + .hdr) -- note the hdr is the only thing that differs.</div>

<div><br></div><div>I have written a script that allows me to simply append this info after I've written the file to ENVI format with writeRaster, but I wanted to know there was some way to do this from within writeRaster.</div>


<div><br></div><div>Incidentally, here are the R variables:</div><div>class_names=c("Unclassified",</div><div><span style="white-space:pre-wrap">             </span>"temperature_min",</div><div><span style="white-space:pre-wrap">             </span>"temperature_max",</div>

<div><span style="white-space:pre-wrap">          </span>"temperature_var",</div><div><span style="white-space:pre-wrap">             </span>"precipitation_mean",</div><div><span style="white-space:pre-wrap">          </span>"precipitation_var",</div>

<div><span style="white-space:pre-wrap">          </span>"wnd_mean",</div><div><span style="white-space:pre-wrap">            </span>"rad_mean",</div><div><span style="white-space:pre-wrap">            </span>"eto_mean",</div>

<div><span style="white-space:pre-wrap">          </span>"aet_mean",</div><div><span style="white-space:pre-wrap">            </span>"def_mean"</div><div>)</div><div>class_number=length(class_names)</div><div>
<br></div><div># I don't know if the formatting matters for ENVI</div><div>class_colors=format(</div><div><span style="white-space:pre-wrap">     </span>as.character(c(0,0,0,as.vector(col2rgb(rainbow(n=(class_number-1)))))),</div>

<div><span style="white-space:pre-wrap">  </span>width=4,justify="right")</div><div class="gmail_extra"><br></div><div class="gmail_extra"># The string to append to the header file should be:</div><div class="gmail_extra">

<div class="gmail_extra"><span style="white-space:pre-wrap">    </span>if(length(var_value)==1)</div><div class="gmail_extra"><span style="white-space:pre-wrap">   </span>{</div><div class="gmail_extra"><span style="white-space:pre-wrap">          </span>header_string=paste(var_name,var_value,sep=" = ")</div>

<div class="gmail_extra"><span style="white-space:pre-wrap">    </span>} else</div><div class="gmail_extra"><span style="white-space:pre-wrap">     </span>{</div><div class="gmail_extra"><span style="white-space:pre-wrap">          </span>header_string=paste(var_name," = {",(paste(var_value,collapse=", ")),"}",sep="")</div>

<div class="gmail_extra"><span style="white-space:pre-wrap">            </span># Use brackets</div><div class="gmail_extra"><span style="white-space:pre-wrap">     </span>}</div><div class="gmail_extra"><br></div></div><div class="gmail_extra">
# where var_name would be </div>
<div class="gmail_extra">var_name="classes"</div><div class="gmail_extra">var_value=class_number</div><div class="gmail_extra"># and..<br>var_name="class lookup"</div><div class="gmail_extra">
var_value=class_colors</div><div class="gmail_extra"># and...</div><div class="gmail_extra">var_name="class names"</div><div class="gmail_extra">var_value=class_names<br><br># I haven't written code to swap in "file type = ENVI Classification" yet, but that also would need to be modded.<br>

<br>Thanks!</div><div class="gmail_extra"><br></div><div class="gmail_extra">--j<br><br><div class="gmail_quote">On Sat, Jan 5, 2013 at 2:55 PM, Roger Bivand <span dir="ltr"><<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">This is a continuation of thread: gdal color tables:<br>
<br>
<a href="https://stat.ethz.ch/pipermail/r-sig-geo/2013-January/017120.html" target="_blank">https://stat.ethz.ch/<u></u>pipermail/r-sig-geo/2013-<u></u>January/017120.html</a><br>
<br>
continued from:<br>
<br>
<a href="https://stat.ethz.ch/pipermail/r-sig-geo/2012-December/017071.html" target="_blank">https://stat.ethz.ch/<u></u>pipermail/r-sig-geo/2012-<u></u>December/017071.html</a><br>
<br>
Could you please try to use the results there with the ENVI driver? If you have a small example file showing what you want to achieve, that might help.<br>
<br>
Roger<div><div><br>
<br>
<br>
On Sat, 5 Jan 2013, Jonathan Greenberg wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Folks:<br>
<br>
I was wondering if there is any support for writing an ENVI classification<br>
file (which contains additional header info to assign the number of<br>
classes, the color as RGB values, and class names to each class).  Here's<br>
an example from the ENVI header:<br>
<br>
classes = 11<br>
class lookup = {<br>
  0,   0,   0, 255,   0,   0, 139,   0,   0, 205,   0,   0,   0,   0, 255,<br>
  0, 255, 255, 238, 210, 238, 255, 255,   0, 160,  32, 240,   0,   0, 139,<br>
255, 165,   0}<br>
class names = {<br>
Unclassified, temperature_min, temperature_max, temperature_var,<br>
precipitation_mean, precipitation_var, wnd_mean, rad_mean, eto_mean,<br>
aet_mean, deficit_mean}<br>
<br>
Specifically I'd like to use writeRaster to do it, but I assume this is an<br>
issue with passing rgdal the right info...<br>
<br>
--j<br>
<br>
<br>
</blockquote>
<br>
-- <br></div></div><span><font color="#888888">
Roger Bivand<br>
Department of Economics, NHH Norwegian School of Economics,<br>
Helleveien 30, N-5045 Bergen, Norway.<br>
voice: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55</a>; fax <a href="tel:%2B47%2055%2095%2095%2043" value="+4755959543" target="_blank">+47 55 95 95 43</a><br>
e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Jonathan A. Greenberg, PhD<br>Assistant Professor<div>Global Environmental Analysis and Remote Sensing (GEARS) Laboratory<br>Department of Geography and Geographic Information Science<br>


University of Illinois at Urbana-Champaign<br>607 South Mathews Avenue, MC 150<br>Urbana, IL 61801<br><span>Phone: <span title="Call with Google Voice"><a href="tel:217-300-1924" value="+12173001924" target="_blank">217-300-1924</a></span></span><div>

<a href="http://www.geog.illinois.edu/~jgrn/" target="_blank">http://www.geog.illinois.edu/~jgrn/</a><br>
AIM: jgrn307, MSN: <a href="mailto:jgrn307@hotmail.com" target="_blank">jgrn307@hotmail.com</a>, Gchat: jgrn307, Skype: jgrn3007<br></div></div></div>
</div></div>