<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks very much Chaitanya, that was indeed my problem.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I am using gdal_grid to create the image that I am filtering, and am setting &quot;nodata=255&quot; as a parameter on the interpolation algorithm.  I had expected that this would cause nodata areas to be written as 255, and that 255 would be marked as the nodata value in the output image (geotiff) metadata, but apparently only the former is true, and I need to run the output through gdal_translate as you indicate in order to set the metadata.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks again,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>--Ken<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> gdal-dev-bounces@lists.osgeo.org [mailto:gdal-dev-bounces@lists.osgeo.org] <b>On Behalf Of </b>Chaitanya kumar CH<br><b>Sent:</b> Thursday, November 18, 2010 10:59 PM<br><b>To:</b> Boss, Ken (DNR)<br><b>Cc:</b> gdal-dev@lists.osgeo.org<br><b>Subject:</b> Re: [gdal-dev] KernelFilteredSource and nodata<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Ken,<br><br>KernelFilteredSource is derived from SimpleSource. It does not support setting a nodata value to the source band.<br>Make sure your source image has a nodata value. You can set it using gdal_translate with the -a_nodata option.<o:p></o:p></p><div><p class=MsoNormal>On Fri, Nov 19, 2010 at 2:10 AM, Boss, Ken (DNR) &lt;<a href="mailto:Ken.Boss@state.mn.us">Ken.Boss@state.mn.us</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal>Chaitanya--<br><br>Thanks much for your response.<br><br>I don't think that I described my problem effectively. &nbsp;Let me restate it and see if we are talking about the same thing.<br><br>Here is a .vrt file that I think should accomplish what I am after:<o:p></o:p></p><div><p class=MsoNormal><br>&lt;VRTDataset rasterYSize='690' rasterXSize='575'&gt;<br>&nbsp;&lt;SRS&gt;EPSG:26915&lt;/SRS&gt;<br>&nbsp;&lt;GeoTransform&gt;190000, 1000, 0, 4795000, 0, 1000&lt;/GeoTransform&gt;<br>&nbsp;&lt;VRTRasterBand band='1' dataType='Byte'&gt;<br>&nbsp; &nbsp;&lt;KernelFilteredSource&gt;<o:p></o:p></p></div><p class=MsoNormal>&nbsp; &nbsp; &nbsp;&lt;SourceFilename&gt;D:/MyFiles/aptana_workspace/fire-webpage-mgmt/data/tmp_images/interpolated.tif&lt;/SourceFilename&gt;<o:p></o:p></p><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp;&lt;SourceBand&gt;1&lt;/SourceBand&gt;<br>&nbsp; &nbsp; &nbsp;&lt;NoDataValue&gt;255&lt;/NoDataValue&gt;<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>&nbsp; &nbsp; &nbsp;&lt;Kernel normalized=&quot;1&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&lt;Size&gt;5&lt;/Size&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&lt;Coefs&gt;0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04&lt;/Coefs&gt;<br>&nbsp; &nbsp; &nbsp;&lt;/Kernel&gt;<br>&nbsp; &nbsp;&lt;/KernelFilteredSource&gt;<br>&nbsp;&lt;/VRTRasterBand&gt;<br>&lt;/VRTDataset&gt;<o:p></o:p></p></div><p class=MsoNormal>I believe this file to be saying that interpolated.tif uses a value of 255 for nodata, and that the kernel is to be normalized - that is, it should:<br><br>&nbsp;o ignore any nodata pixels within the kernel window when operating on a valid pixel<br>&nbsp;o adjust the coefficients to sum to one for the number of valid pixels in the window when operating on a valid pixel<br>&nbsp;o do nothing at all when centered on a nodata pixel<br><br>I would expect then that any pixels that go in as nodata should come out as nodata, and that pixels with valid data values that are near nodata pixels should not be influenced by them.<br><br>However, the outputs are not what I expect. &nbsp;The averaging is applied to both nodata and valid pixels alike. &nbsp;Have I set this up correctly, and is there a bug somewhere, or (more likely) is my vrt improperly constructed?<br><br>Thanks for your help,<br><span style='color:#888888'><br>--Ken</span><o:p></o:p></p><div><div><p class=MsoNormal><br>&gt; -----Original Message-----<br>&gt; From: Chaitanya kumar CH [mailto:<a href="mailto:chaitanya.ch@gmail.com">chaitanya.ch@gmail.com</a>]<br>&gt; Sent: Wednesday, November 17, 2010 11:11 PM<br>&gt; To: Boss, Ken (DNR)<br>&gt; Cc: <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>&gt; Subject: Re: [gdal-dev] KernelFilteredSource and nodata<br>&gt;<br>&gt; Ken,<br>&gt;<br>&gt; The current kernel filter does not ignore the boundaries of nodata pixels. But it<br>&gt; does normalize the kernel after ignoring the nodata pixels in the kernel, if the<br>&gt; 'normalized' attribute is set to 1.<br>&gt;<br>&gt; You can raise a ticket to request for this feature at<br>&gt; <a href="http://trac.osgeo.org/gdal/newticket" target="_blank">http://trac.osgeo.org/gdal/newticket</a><br>&gt;<br>&gt;&gt; On Thu, Nov 18, 2010 at 6:08 AM, Boss, Ken (DNR) &lt;<a href="mailto:Ken.Boss@state.mn.us">Ken.Boss@state.mn.us</a>&gt;<br>&gt;&gt; wrote:<br>&gt;&gt; Hello list--<br>&gt;&gt;<br>&gt;&gt; I am attempting to filter a raster using gdal_translate (v 1.7) and a vrt with a<br>&gt;&gt; KernelFilteredSource. &nbsp;The input raster contains large areas of &quot;nodata&quot; values. &nbsp;I<br>&gt;&gt; would like the filter to ignore those areas. &nbsp;I have tried various combinations of<br>&gt;&gt; &lt;NoDataValue&gt;, &lt;HideNoDataValue&gt;, &lt;NODATA&gt; and &lt;Kernel normalized='1'&gt;,<br>&gt;&gt; but have not been able to prevent the filter from applying itself at data/nodata<br>&gt;&gt; boundaries.<br>&gt;&gt;<br>&gt;&gt; My current VRT and gdal_translate command lines are below. &nbsp;Can anyone tell me<br>&gt;&gt; what I am doing wrong?<br>&gt;&gt;<br>&gt;&gt; Thanks,<br>&gt;&gt;<br>&gt;&gt; Ken Boss<br>&gt;&gt; Minnesota DNR<br>&gt;&gt;<br>&gt;&gt; ===== kernel_filter.vrt ===================<br>&gt;&gt;<br>&gt;&gt; &lt;VRTDataset rasterYSize='690' rasterXSize='575'&gt;<br>&gt;&gt; &nbsp;&lt;SRS&gt;EPSG:26915&lt;/SRS&gt;<br>&gt;&gt; &nbsp;&lt;GeoTransform&gt;190000, 1000, 0, 4795000, 0, 1000&lt;/GeoTransform&gt;<br>&gt;&gt; &nbsp;&lt;VRTRasterBand band='1' dataType='Byte'&gt;<br>&gt;&gt; &nbsp; &nbsp;&lt;KernelFilteredSource&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;SourceFilename&gt;interpolated.tif&lt;/SourceFilename&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;SourceBand&gt;1&lt;/SourceBand&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;NoDataValue&gt;255&lt;/NoDataValue&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;HideNoDataValue&gt;1&lt;/HideNoDataValue&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;Kernel normalized='1'&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Size&gt;5&lt;/Size&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Coefs&gt;0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04<br>&gt;&gt; 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04&lt;/Coefs&gt;<br>&gt;&gt; &nbsp; &nbsp; &nbsp;&lt;/Kernel&gt;<br>&gt;&gt; &nbsp; &nbsp;&lt;/KernelFilteredSource&gt;<br>&gt;&gt; &nbsp;&lt;/VRTRasterBand&gt;<br>&gt;&gt; &lt;/VRTDataset&gt;<br>&gt;&gt;<br>&gt;&gt; =====================================<br>&gt;&gt;<br>&gt;&gt; gdal_translate -of GTiff -ot Byte -a_srs EPSG:26915 kernel_filter.vrt<br>&gt;&gt; kernel_filtered.tif<br>&gt;&gt;<br>&gt; _______________________________________________<br>&gt; gdal-dev mailing list<br>&gt; <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>&gt; <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>&gt; Best regards,<br>&gt; Chaitanya kumar CH.<br>&gt; /t<span style='font-family:"MS Mincho"'>ʃ</span>a<span style='font-family:"MS Mincho"'>ɪ</span>θənjə/ /k<span style='font-family:"MS Mincho"'>ʊ</span>m<span style='font-family:"MS Mincho"'>ɑ</span>r/<br>&gt; +91-9494447584<br>&gt; 17.2416N 80.1426E<o:p></o:p></p></div></div></div><p class=MsoNormal><br><br clear=all><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>/t<span style='font-family:"MS Mincho"'>ʃ</span>a<span style='font-family:"MS Mincho"'>ɪ</span>θənjə/ /k<span style='font-family:"MS Mincho"'>ʊ</span>m<span style='font-family:"MS Mincho"'>ɑ</span>r/ <br>+91-9494447584<br>17.2416N 80.1426E<o:p></o:p></p></div></div></body></html>