[gdal-dev] gdaladdo, overviews and NODATA

Armin Burger armin.burger at gmx.net
Tue Feb 21 16:17:34 EST 2012


Frank

the original images showed
...
Metadata:
   AREA_OR_POINT=Area
Image Structure Metadata:
   INTERLEAVE=PIXEL
...
Band 1 Block=3000x1 Type=Byte, ColorInterp=Red
Band 2 Block=3000x1 Type=Byte, ColorInterp=Green
Band 3 Block=3000x1 Type=Byte, ColorInterp=Blue

Then I tried to set the NODATA value to 0 using Gdal-Python, and 
afterwards they had

Band 1 Block=3000x1 Type=Byte, ColorInterp=Red
   NoData Value=0
Band 2 Block=3000x1 Type=Byte, ColorInterp=Green
   NoData Value=0
Band 3 Block=3000x1 Type=Byte, ColorInterp=Blue
   NoData Value=0

But the result was the same, when using "-r average" a 1-2 pixel area of 
the original NODATA values along the border to the DATA areas seem to 
have got pixels with higher values than 0 (at least in Mapserver they 
cannot any more be "hidden" with OFFSITE). Is there a simple way to 
write out the overviews to separate Tiff files so that I can check them 
directly?

Armin


On 21/02/2012 21:48, Frank Warmerdam wrote:
> Armin,
>
> Reviewing the overview building code in gdal/gcore/overview.cpp
> it clearly tries to exclude nodata values from the averaging calculation.
> What does the gdalinfo report look like for the file before you run
> gdaladdo?
>
> Best regards,
>
> On Tue, Feb 21, 2012 at 12:36 PM, Armin Burger<armin.burger at gmx.net>  wrote:
>> Hi all
>>
>> I have a question regarding the gdaladdo tool and NODATA pixels:
>>
>> When using resampling like "average" it seems that along the border of DATA
>> and NODATA pixels there happens an averaging also of some of the original
>> NODATA pixels (looks like 1-2 pixel width). This way in the overviews they
>> get values higher than 0 (0 is defined as NODATA). Using this type of data
>> in mapserver leads to small black borders when the overviews are taken since
>> the tag
>>   OFFSITE 0 0 0
>> does not work anymore for the small border of now only "nearly-black"
>> pixels.
>>
>> I tried to set the metadata NODATA of the images to 0 for each band but it
>> had no effect. Only when I use resampling "nearest" then every NODATA pixel
>> of the overviews retains the full black 0 0 0.
>>
>> Is there a way to force to exclude NODATA pixels during the "average"
>> resampling so that they retain their NODATA values?
>>
>> Thanks
>> Armin
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>


More information about the gdal-dev mailing list