<div dir="ltr">Ari,<div><br></div><div>It looks like you have a raster with classified pixel values. If the number of RGB sets is not more than 256, you can convert it to 8 bit paletted image using rgb2pct.py. Then you will have a single band to represent all colors and a single value to represent the set (230,245,255) which can be set as nodata.</div><div><br></div><div>Also, if you look at the example in the doc page of that script, there is a way to create a color table. You can edit that vrt file to set the pixels with those values to transparent by setting c4 to 0.</div><div><br></div><div><a href="http://www.gdal.org/rgb2pct.html">http://www.gdal.org/rgb2pct.html</a><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 10, 2015 at 11:42 PM Ari Simmons <<a href="mailto:ari.ucb.fire@gmail.com">ari.ucb.fire@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hm. Yeah. I don't think this is going to work...<div><br></div><div>I need to remove whatever pixel has the 3 values '<span style="font-family:'Times New Roman',serif;font-size:16px"> </span><span style="font-family:'Times New Roman',serif;font-size:16px">230, 245, 255' ...which is different then removing from Band 1 = 230, Band 2 = 245, Band 3 = 255. If I do that, I am 'NoData'ing' values I probably want to keep (for ex: '230 246 255' would become '0 246 0'....not right.)</span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px"><br></span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px">Ok. So to do this another way...is there an elegant way to go from a 3 Band to a 1 Band image (other then just taking 1 of the 2 bands). I know there is a way to go from a Grayscale 1-band to a 3-band RGB ...but is there an inverse of that?</span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px"><br></span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px"><br></span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px"><br></span></div><div><span style="font-family:'Times New Roman',serif;font-size:16px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 10, 2015 at 10:53 AM, <span dir="ltr"><<a href="mailto:Matt.Wilkie@gov.yk.ca" target="_blank">Matt.Wilkie@gov.yk.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-CA" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">That vrt snippet looks correct. Only one nodata number per band, and it has the correct value, 230.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">In my test file 2 or so lines above <ComplexSource> there is an additional line “<NoDataValue>” with the number as a scaled float,
“1.80000000000000E+001” (the +001 at end means move decimal to right 1 time. My nodata here is “18”). Full file is attached.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Matt<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Ari Simmons [mailto:<a href="mailto:ari.ucb.fire@gmail.com" target="_blank">ari.ucb.fire@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, June 10, 2015 10:24 AM<br>
<b>To:</b> Matt.Wilkie<br>
<b>Cc:</b> Chaitanya kumar CH; <a href="mailto:fwtools@lists.maptools.org" target="_blank">fwtools@lists.maptools.org</a><br>
<b>Subject:</b> Re: [FWTools] gdal_merge with a specific pixel value clipped/removed<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Matt <br>
<br>
Not sure I see how...<br>
<br>
<ComplexSource><br>
<SourceFilename relativeToVRT="1">TEX_N00E006.tif</SourceFilename><br>
<SourceBand>1</SourceBand><br>
<SourceProperties RasterXSize="1200" RasterYSize="1200" DataType="Byte" BlockXSize="1200" BlockYSize="2" /><br>
<SrcRect xOff="0" yOff="0" xSize="1200" ySize="1200" /><br>
<DstRect xOff="0" yOff="0" xSize="1200" ySize="1200" /><br>
<NODATA>230</NODATA><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Do you mean change <br>
<br>
<NODATA>230</NODATA><u></u><u></u></p>
</div>
<p class="MsoNormal">to <br>
<br>
<NODATA>230 245 255</NODATA><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Jun 10, 2015 at 10:20 AM, <<a href="mailto:Matt.Wilkie@gov.yk.ca" target="_blank">Matt.Wilkie@gov.yk.ca</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Perhaps try editing the .vrt file with a text editor and changing the nodata value by hand?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Matt</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">
<a href="mailto:fwtools-bounces@lists.maptools.org" target="_blank">fwtools-bounces@lists.maptools.org</a> [mailto:<a href="mailto:fwtools-bounces@lists.maptools.org" target="_blank">fwtools-bounces@lists.maptools.org</a>]
<b>On Behalf Of </b>Ari Simmons<br>
<b>Sent:</b> Wednesday, June 10, 2015 10:19 AM<br>
<b>To:</b> Chaitanya kumar CH<br>
<b>Cc:</b> <a href="mailto:fwtools@lists.maptools.org" target="_blank">fwtools@lists.maptools.org</a><br>
<b>Subject:</b> Re: [FWTools] gdal_merge with a specific pixel value clipped/removed</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Ok - so gdal_translate works great! Thanks!<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">HOWEVER, the removal of value 230 245 255 is still no happening...when I put in:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">>>gdalbuildvrt -srcnodata "230 245 255" tif_index.vrt *.tif<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I get a .vrt with Band 1 = 0 (instead of 230) and the full 3 Band value becoming (0 245 255)....not what I expected. I expected it to become "NoData"....<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Jun 9, 2015 at 9:17 PM, Chaitanya kumar CH <<a href="mailto:chaitanya.ch@gmail.com" target="_blank">chaitanya.ch@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Ari,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">The vrt is an xml file that represents a single raster dataset made up of one or many rasters. So, it is already merged. You can read it using any good text editor.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">You only have to run gdal_translate to convert it to a tif.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">gdal_translate -of GTiff tif_index.vrt tif_index.tif<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jun 10, 2015 at 2:40 AM Ari Simmons <<a href="mailto:ari.ucb.fire@gmail.com" target="_blank">ari.ucb.fire@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Interesting...ok, so (knowing nothing about .vrt's and having a bunch of .tiff's) I ran this:<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">>>gdalbuildvrt -srcnodata "230 245 255" tif_index.vrt *.tif<br>
0...10...20...30...40...50...60...70...80...90...100 - done.<u></u><u></u></p>
</div>
<p class="MsoNormal">then<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">>> gdal_merge -o merged_result.tif *.vrt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">and got<br>
<br>
ERROR 4: `*.vrt' does not exist in the file system,<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
and is not recognised as a supported dataset name.<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">I'm on OSGEO4W too..<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Jun 9, 2015 at 1:24 PM, <<a href="mailto:Matt.Wilkie@gov.yk.ca" target="_blank">Matt.Wilkie@gov.yk.ca</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">The error is because you need to quote the argument values to keep them from being interpreted as filenames:<br>
<br>
gdal_merge -n “230 245 255” ...<br>
<br>
However gdal_merge can't use different nodata values for each band. You need to pre-process the files before merging. This worked for me here:<br>
<br>
Create VRT (virtual raster) file for the input file(s):<br>
<br>
gdalbuildvrt -srcnodata "230 245 255”" infile1.vrt infile1.tif<br>
<br>
Then feed the .vrt's to gdal_merge:<br>
<br>
gdal_merge -of merged_result.tif infile1.vrt infile2.vrt ...<br>
<br>
<br>
You may need to switch from fwtools to Osgeo4w (if on Windows) to get gdalbuildvrt.<br>
<br>
Cheers,<br>
<br>
--<br>
matt wilkie<br>
--------------------------------------------<br>
Geomatics Analyst<br>
Information Management and Technology<br>
Yukon Department of Environment<br>
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9<br>
<a href="tel:867-667-8133" target="_blank">867-667-8133</a> Tel * <a href="tel:867-393-7003" target="_blank">
867-393-7003</a> Fax<br>
<a href="http://environmentyukon.gov.yk.ca/geomatics/" target="_blank">http://environmentyukon.gov.yk.ca/geomatics/</a><br>
--------------------------------------------<br>
<br>
<br>
<br>
-----------------------------<br>
<br>
From: <a href="mailto:fwtools-bounces@lists.maptools.org" target="_blank">fwtools-bounces@lists.maptools.org</a> [mailto:<a href="mailto:fwtools-bounces@lists.maptools.org" target="_blank">fwtools-bounces@lists.maptools.org</a>] On Behalf Of Ari Simmons<br>
Sent: Tuesday, June 09, 2015 12:43 PM<br>
To: <a href="mailto:fwtools@lists.maptools.org" target="_blank">fwtools@lists.maptools.org</a><br>
Subject: [FWTools] gdal_merge with a specific pixel value clipped/removed<br>
<br>
I have a large set of .tif files and I need to merge/mosaic them all into one .tif with the no-data value removed (i.e. value 230, 245, 255). However, when I put this in...pixel '230, 245, 255' becomes '0, 245, 255').<br>
I am trying to get NO PIXEL returned for 230, 245, 255. Is that possible?<br>
I:\TFS_6\trial_merge>gdal_merge.py -o test.tif -n 230 245 255 file1.tif file2.tif<br>
<br>
ERROR 4: `245' does not exist in the file system,<br>
and is not recognised as a supported dataset name.<br>
<br>
ERROR 4: `255' does not exist in the file system,<br>
and is not recognised as a supported dataset name.<br>
<br>
0...10...20...30...40...50...60...70...80...90...100 - done.<u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">_______________________________________________<br>
FWTools mailing list<br>
<a href="mailto:FWTools@lists.maptools.org" target="_blank">FWTools@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/fwtools" target="_blank">http://lists.maptools.org/mailman/listinfo/fwtools</a><br>
<a href="http://fwtools.maptools.org/" target="_blank">http://fwtools.maptools.org/</a><span><font color="#888888"><u></u><u></u></font></span></p><span><font color="#888888">
</font></span></blockquote><span><font color="#888888">
</font></span></div><span><font color="#888888">
</font></span></div><span><font color="#888888">
</font></span></div><span><font color="#888888">
<div>
<p class="MsoNormal"><span style="color:#888888">--
<u></u><u></u></span></p>
</div>
<p><span style="color:#888888">Chaitanya Kumar CH<u></u><u></u></span></p>
</font></span></blockquote><span><font color="#888888">
</font></span></div><span><font color="#888888">
<p class="MsoNormal"> <u></u><u></u></p>
</font></span></div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote></div><br></div>
</blockquote></div></div></div><div dir="ltr">-- <br></div><p dir="ltr">Chaitanya Kumar CH</p>