7 | | |
8 | | == What if '''nodata''' is different in each image? == |
9 | | |
10 | | If the ''nodata'' tag is set in the geotiff header, gdalwarp will use it automatically, you don't need to do anything. However, `-srcnodata` overrides this, so if you are handling a bunch of images with different values to be ignored you need to either a) pre-process them to have the same to-be-ignored value, or b) set the nodata flag for each file. Use (b) if you need to preserve the original values for some reason, for example: |
11 | | |
12 | | {{{ |
13 | | # for this image we want to ignore black (0) |
14 | | gdalwarp -srcnodata 0 -dstnodata 0 orig-ignore-black.tif black-nodata.tif |
15 | | |
16 | | # and now we want to ignore white (0) |
17 | | gdalwarp -srcnodata 255 -dstnodata 255 orig-ignore-white.tif white-nodata.tif |
18 | | |
19 | | # and finally ignore a particular blue-grey (RGB 125 125 150) |
20 | | gdalwarp -srcnodata "125 125 150" -dstnodata "125 125 150" orig-ignore-grey.tif grey-nodata.tif |
21 | | |
22 | | # now we can mosaic them all and not worry about nodata parameters |
23 | | gdalwarp -dstnodata 0 black-nodata.tif grey-nodata.tif white-nodata.tif final-mosaic.tif |
24 | | }}} |
25 | | |
26 | | If you are wondering why the `-dstnodata` is there, it's because although gdalwarp automatically honours input nodata, but before GDAL 1.11, it didn't carry that through unless instructed up. |