[Gdal-dev] Killing nodata images
Frank Warmerdam
warmerdam at pobox.com
Thu Jun 8 19:53:04 EDT 2006
Doug_Newcomb at fws.gov wrote:
> Hi folks,
> I've written a python script to chop large .sid files into 10,000 x
> 10,000 pixel tiff , prior to conversion to .ecw format. The sid files are
> countywide mosaics of aerial photographs. Since not a lot of the counties
> in this state are square, there can be large nodata sections in the sid
> files. This means that some of the the blocks I chop out may be composed
> entirely of nodata areas. I've been trying to figure out a quick way to
> determine if a file is entirely made up of nodata pixels while it's in tiff
> format, so I can delete it before wasting the cpu cycles converting it to
> ecw.
>
> I'm fairly sure I'm missing something obvious due to my lack of
> skill with python and lack of understanding of how the gdal -python
> interface works, so all suggestions welcome.
Doug,
If you call GetMaximum() on a gdal.Band and it returns a very small value
then it is likely that the entire image is black or near black (assuming black
is your nodata value). You could check if band.GetMinimum() ==
band.GetMaximum() == nodata value, but if you are coming from sid there may
be some noise that would make it inexact. In that case checking for
min/max being close to the nodata value.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGF, http://osgeo.org
More information about the Gdal-dev
mailing list