[gdal-dev] KernelFilteredSource and nodata

Boss, Ken (DNR) Ken.Boss at state.mn.us
Thu Nov 18 15:40:05 EST 2010


Chaitanya--

Thanks much for your response.

I don't think that I described my problem effectively.  Let me restate it and see if we are talking about the same thing.

Here is a .vrt file that I think should accomplish what I am after:

<VRTDataset rasterYSize='690' rasterXSize='575'>
  <SRS>EPSG:26915</SRS>
  <GeoTransform>190000, 1000, 0, 4795000, 0, 1000</GeoTransform>
  <VRTRasterBand band='1' dataType='Byte'>
    <KernelFilteredSource>
      <SourceFilename>D:/MyFiles/aptana_workspace/fire-webpage-mgmt/data/tmp_images/interpolated.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <NoDataValue>255</NoDataValue>
      <Kernel normalized="1">
        <Size>5</Size>
        <Coefs>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</Coefs>
      </Kernel>
    </KernelFilteredSource>
  </VRTRasterBand>
</VRTDataset>

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:

 o ignore any nodata pixels within the kernel window when operating on a valid pixel
 o adjust the coefficients to sum to one for the number of valid pixels in the window when operating on a valid pixel
 o do nothing at all when centered on a nodata pixel

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.

However, the outputs are not what I expect.  The averaging is applied to both nodata and valid pixels alike.  Have I set this up correctly, and is there a bug somewhere, or (more likely) is my vrt improperly constructed?

Thanks for your help,

--Ken 

> -----Original Message-----
> From: Chaitanya kumar CH [mailto:chaitanya.ch at gmail.com]
> Sent: Wednesday, November 17, 2010 11:11 PM
> To: Boss, Ken (DNR)
> Cc: gdal-dev at lists.osgeo.org
> Subject: Re: [gdal-dev] KernelFilteredSource and nodata
> 
> Ken,
> 
> The current kernel filter does not ignore the boundaries of nodata pixels. But it
> does normalize the kernel after ignoring the nodata pixels in the kernel, if the
> 'normalized' attribute is set to 1.
> 
> You can raise a ticket to request for this feature at
> http://trac.osgeo.org/gdal/newticket
> 
>> On Thu, Nov 18, 2010 at 6:08 AM, Boss, Ken (DNR) <Ken.Boss at state.mn.us>
>> wrote:
>> Hello list--
>> 
>> I am attempting to filter a raster using gdal_translate (v 1.7) and a vrt with a
>> KernelFilteredSource.  The input raster contains large areas of "nodata" values.  I
>> would like the filter to ignore those areas.  I have tried various combinations of
>> <NoDataValue>, <HideNoDataValue>, <NODATA> and <Kernel normalized='1'>,
>> but have not been able to prevent the filter from applying itself at data/nodata
>> boundaries.
>> 
>> My current VRT and gdal_translate command lines are below.  Can anyone tell me
>> what I am doing wrong?
>> 
>> Thanks,
>> 
>> Ken Boss
>> Minnesota DNR
>> 
>> ===== kernel_filter.vrt ===================
>> 
>> <VRTDataset rasterYSize='690' rasterXSize='575'>
>>  <SRS>EPSG:26915</SRS>
>>  <GeoTransform>190000, 1000, 0, 4795000, 0, 1000</GeoTransform>
>>  <VRTRasterBand band='1' dataType='Byte'>
>>    <KernelFilteredSource>
>>      <SourceFilename>interpolated.tif</SourceFilename>
>>      <SourceBand>1</SourceBand>
>>      <NoDataValue>255</NoDataValue>
>>      <HideNoDataValue>1</HideNoDataValue>
>>      <Kernel normalized='1'>
>>        <Size>5</Size>
>>        <Coefs>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</Coefs>
>>      </Kernel>
>>    </KernelFilteredSource>
>>  </VRTRasterBand>
>> </VRTDataset>
>> 
>> =====================================
>> 
>> gdal_translate -of GTiff -ot Byte -a_srs EPSG:26915 kernel_filter.vrt
>> kernel_filtered.tif
>> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 
> 
> --
> Best regards,
> Chaitanya kumar CH.
> /tʃaɪθənjə/ /kʊmɑr/
> +91-9494447584
> 17.2416N 80.1426E


More information about the gdal-dev mailing list