[gdal-dev] Setting the noData flag in a GeoTIFF

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Wed Dec 4 04:16:39 PST 2013


Jonathan Moules <jonathanmoules <at> warwickshire.gov.uk> writes:

> 
> 
> Hi Jukka,Good point. In fact, that's one of the reasons I want to set the
noData flag. I figure when compressing hopefully the compressor will see
that it is "noData" and will treat it differently from the way it would an
actual value (which results in things like your mentioned 255,255,254) so I
won't get the white-border-effect. I guess I'll find out if/when I get to
that point.

Hi,

As far as I know GDAL does not do miracles. You cannot make a perfect result
with rotated images, noData value and jpeg compression if you warp first and
mosaic afterwards.  If you want to use jpeg compression, as I suppose you
do, turn the order and mosaic first - warp next. Build a virtual mosaic when
you still play in the world of the native projection and warp images to
target projection by using –projwin.  That way at least the images from the
middle parts of your site will be rectangular and without noData areas at
all in the target srs and you will have no issues with jpeg compression. You
will still get non-transparent pixels into the borders of your site but you
can create those images  without compression or with lossless LZW/deflate
compression.

You are anyways so well oriented in doing controlled tests that you will
probably do little experiments with your own data and mosaics of size 2x2 or
3x3 tiles before running huge batches.

However, if your originals don't have white borders of noData areas withing
the image area then you will not have them either after running your commands.

gdalbuildvrt -hidenodata -srcnodata 255 -vrtnodata 255 -input_file_list
tiff_list.txt 255.vrt

gdal_translate -of GTiff -co TILED=YES -co BIGTIFF=YES -co COMPRESS=JPEG 
-co JPEG_QUALITY=80 -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co
PHOTOMETRIC=YCBCR 255.vrt 255mask.tif

In this case using noData is not necessary either and may actually burn
holes into your images if there are some extremely light areas of dry, plain
terrain or the sun is reflecting from the water bodies and roofs of the
buildings etc.

-Jukka-




More information about the gdal-dev mailing list