Modify an image color table?<br>-- SOLVED --<br><br>Thanks a lot Frank and Luke.<br><br>This is the solution of my problem:<br>1) I built *.vrt file from ASCII file;<br>2) I used the &lt;LUT&gt; command like this:<br><br>----------------------------------------------------------------------------------------------------------<br>
  &lt;VRTRasterBand dataType=&quot;Byte&quot; band=&quot;1&quot;&gt;<br>   &lt;ColorInterp&gt;Red&lt;/ColorInterp&gt;<br>    &lt;ComplexSource&gt;<br>      &lt;SourceFilename relativeToVRT=&quot;1&quot;&gt;file.asc&lt;/SourceFilename&gt;<br>
      &lt;SourceBand&gt;1&lt;/SourceBand&gt;<br>     &lt;LUT&gt;<br>-9999:0,<br>-31:99,<br>-30:99,<br>-29:99,<br>-28:99,<br>-27:99,<br>-26:99,<br>-25:99,<br>-24:99,<br>-23:99,<br>-22:99,<br>-21:99,<br>-20:99,<br>-19:99,<br>
-18:99,<br>-17:99,<br>-16:99,<br>-15:20,<br>-14:20,<br>-13:20,<br>-12:20,<br>-11:20,<br>-10:8,<br>-9:8,<br>-8:8,<br>-7:8,<br>-6:8,<br>-5:5,<br>-4:5,<br>-3:5,<br>-2:5,<br>-1:5,<br>0:3,<br>1:3,<br>2:3,<br>3:3,<br>4:3,<br>5:1,<br>
6:1,<br>7:1,<br>8:1,<br>9:1,<br>10:1,<br>11:1,<br>12:1,<br>13:1,<br>14:1,<br>15:30,<br>16:30,<br>17:30,<br>18:30,<br>19:30,<br>20:52,<br>21:52,<br>22:52,<br>23:52,<br>24:52,<br>25:72,<br>26:72,<br>27:72,<br>28:72,<br>29:72,<br>
30:94,<br>31:94,<br>32:94,<br>33:94,<br>34:94,<br>35:100,<br>36:100,<br>37:100,<br>38:100,<br>39:100,<br>40:100,<br>41:100,<br>42:100,<br>43:100,<br>44:100,<br>45:100,<br>46:100,<br>47:100,<br>48:100,<br>49:100,<br>50:100,<br>
51:100,<br>52:100,<br>53:100,<br>54:100,<br>55:100,<br>56:100,<br>57:100,<br>58:100,<br>59:100,<br>60:90,<br>61:90,<br>62:90,<br>63:90,<br>64:90,<br>65:82<br>     &lt;/LUT&gt;<br>    &lt;/ComplexSource&gt;<br>  &lt;/VRTRasterBand&gt;<br>
  &lt;VRTRasterBand dataType=&quot;Byte&quot; band=&quot;2&quot;&gt;<br>   &lt;ColorInterp&gt;Green&lt;/ColorInterp&gt;<br>    &lt;ComplexSource&gt;<br>      &lt;SourceFilename relativeToVRT=&quot;1&quot;&gt;file.asc&lt;/SourceFilename&gt;<br>
      &lt;SourceBand&gt;1&lt;/SourceBand&gt;<br>     &lt;LUT&gt;<br>-9999:0,<br>-31:99,<br>-30:99,<br>-29:99,<br>-28:99,<br>-27:99,<br>-26:99,<br>-25:99,<br>-24:99,<br>-23:99,<br>-22:99,<br>-21:99,<br>-20:99,<br>-19:99,<br>
-18:99,<br>-17:99,<br>-16:99,<br>-15:8,<br>-14:8,<br>-13:8,<br>-12:8,<br>-11:8,<br>-10:22,<br>-9:22,<br>-8:22,<br>-7:22,<br>-6:22,<br>-5:33,<br>-4:33,<br>-3:33,<br>-2:33,<br>-1:33,<br>0:42,<br>1:42,<br>2:42,<br>3:42,<br>4:42,<br>
5:60,<br>6:60,<br>7:60,<br>8:60,<br>9:60,<br>10:67,<br>11:67,<br>12:67,<br>13:67,<br>14:67,<br>15:87,<br>16:87,<br>17:87,<br>18:87,<br>19:87,<br>20:91,<br>21:91,<br>22:91,<br>23:91,<br>24:91,<br>25:95,<br>26:95,<br>27:95,<br>
28:95,<br>29:95,<br>30:99,<br>31:99,<br>32:99,<br>33:99,<br>34:99,<br>35:90,<br>36:90,<br>37:90,<br>38:90,<br>39:90,<br>40:79,<br>41:79,<br>42:79,<br>43:79,<br>44:79,<br>45:65,<br>46:65,<br>47:65,<br>48:65,<br>49:65,<br>50:50,<br>
51:50,<br>52:50,<br>53:50,<br>54:50,<br>55:20,<br>56:20,<br>57:20,<br>58:20,<br>59:20,<br>60:1,<br>61:1,<br>62:1,<br>63:1,<br>64:1,<br>65:1<br>     &lt;/LUT&gt;<br>    &lt;/ComplexSource&gt;<br>  &lt;/VRTRasterBand&gt;<br>
  &lt;VRTRasterBand dataType=&quot;Byte&quot; band=&quot;3&quot;&gt;<br>   &lt;ColorInterp&gt;Blue&lt;/ColorInterp&gt;<br>    &lt;ComplexSource&gt;<br>      &lt;SourceFilename relativeToVRT=&quot;1&quot;&gt;file.asc&lt;/SourceFilename&gt;<br>
      &lt;SourceBand&gt;1&lt;/SourceBand&gt;<br>     &lt;LUT&gt;<br>-9999:0,<br>-31:99,<br>-30:99,<br>-29:99,<br>-28:99,<br>-27:99,<br>-26:99,<br>-25:99,<br>-24:99,<br>-23:99,<br>-22:99,<br>-21:99,<br>-20:99,<br>-19:99,<br>
-18:99,<br>-17:99,<br>-16:99,<br>-15:69,<br>-14:69,<br>-13:69,<br>-12:69,<br>-11:69,<br>-10:68,<br>-9:68,<br>-8:68,<br>-7:68,<br>-6:68,<br>-5:65,<br>-4:65,<br>-3:65,<br>-2:65,<br>-1:65,<br>0:64,<br>1:64,<br>2:64,<br>3:64,<br>
4:64,<br>5:60,<br>6:60,<br>7:60,<br>8:60,<br>9:60,<br>10:42,<br>11:42,<br>12:42,<br>13:42,<br>14:42,<br>15:1,<br>16:1,<br>17:1,<br>18:1,<br>19:1,<br>20:1,<br>21:1,<br>22:1,<br>23:1,<br>24:1,<br>25:1,<br>26:1,<br>27:1,<br>
28:1,<br>29:1,<br>30:1,<br>31:1,<br>32:1,<br>33:1,<br>34:1,<br>35:1,<br>36:1,<br>37:1,<br>38:1,<br>39:1,<br>40:1,<br>41:1,<br>42:1,<br>43:1,<br>44:1,<br>45:1,<br>46:1,<br>47:1,<br>48:1,<br>49:1,<br>50:1,<br>51:1,<br>52:1,<br>
53:1,<br>54:1,<br>55:1,<br>56:1,<br>57:1,<br>58:1,<br>59:1,<br>60:20,<br>61:20,<br>62:20,<br>63:20,<br>64:20,<br>65:43<br>     &lt;/LUT&gt;<br>    &lt;/ComplexSource&gt;<br>  &lt;/VRTRasterBand&gt;<br>---------------------------------------------------------------------------------------------------------------------------------------------<br>
<br><br><br><br><br><br><br><br><br><div class="gmail_quote">2010/6/25 Frank Warmerdam <span dir="ltr">&lt;<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">Marco Stelluti wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
I&#39;m a new gdal user and I&#39;ve a little problem.<br>
<br>
I have to modify the color to an ASCII raster.<br>
<br>
1_ I converted the raster using gdalbuildvrt;<br>
2_ I modified the file *.vrt adding:<br>
    &lt;ColorInterp&gt;Palette&lt;/ColorInterp&gt;<br>
 &lt;ColorTable&gt;<br>
&lt;Entry c1=&quot;255&quot; c2=&quot;255&quot; c3=&quot;255&quot; c4=&quot;255&quot;/&gt;<br>
&lt;Entry c1=&quot;0&quot; c2=&quot;0&quot; c3=&quot;150&quot; c4=&quot;255&quot;/&gt;<br>
&lt;Entry c1=&quot;0&quot; c2=&quot;0&quot; c3=&quot;150&quot; c4=&quot;255&quot;/&gt;<br>
.......<br>
 &lt;/ColorTable&gt;<br>
3_ I know: &quot;The entries are ordered and will be assumed to start from color table entry 0&quot;<br>
4_ But I have some negative value on the ASCII raster, the range is from -31 to 65.<br>
5_ How I can resolve this problem?<br>
</blockquote>
<br></div></div>
Marco,<br>
<br>
Generally speaking GDAL color maps do not have an obvious application<br>
to negative or non-integer data.  You could use the &quot;raster attribute table&quot;<br>
mechanism to represent color assignments to negative values, but since so<br>
few applications make use of this data object it is nearly useless to do so.<br>
<br>
What application do you want the color table to work in?  How you handle<br>
the situation will depend on the output application.   If preserving the<br>
original pixel values isn&#39;t important you may want to reprocess/rescale your<br>
raster.<br>
<br>
Best regards,<br><font color="#888888">
-- <br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up   | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/%7Ewarmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush    | Geospatial Programmer for Rent<br>
<br>
</font></blockquote></div><br>