Thanks very much Chaitanya, that was indeed my problem. I am using gdal_grid to create the image that I am filtering, and am setting "nodata=255" 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.
Thanks again, --Ken From: gdal-dev-boun...@lists.osgeo.org [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of Chaitanya kumar CH Sent: Thursday, November 18, 2010 10:59 PM To: Boss, Ken (DNR) Cc: gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] KernelFilteredSource and nodata Ken, KernelFilteredSource is derived from SimpleSource. It does not support setting a nodata value to the source band. Make sure your source image has a nodata value. You can set it using gdal_translate with the -a_nodata option. On Fri, Nov 19, 2010 at 2:10 AM, Boss, Ken (DNR) <ken.b...@state.mn.us<mailto:ken.b...@state.mn.us>> wrote: 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...@gmail.com<mailto:chaitanya...@gmail.com>] > Sent: Wednesday, November 17, 2010 11:11 PM > To: Boss, Ken (DNR) > Cc: gdal-dev@lists.osgeo.org<mailto:gdal-dev@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.b...@state.mn.us<mailto:ken.b...@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@lists.osgeo.org<mailto:gdal-dev@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 -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev