Image with nodata displayed over google basemap
Same image after making nodata transparent
What’s all the racket?
These little artifacts along the edge of the data look like they should be considered nodata however they show up despite setting the nodata to be transparent. Turns out these cells are slightly off-white and were likely introduced during JPEG compression. This can happen with both 0 (black) and 255 (white) nodata values.
Luckily GDAL has a handy tool to deal with this: nearblack. Nearblack takes all the cell values that are nearly black, or in this case white, and coverts them to true black or white.
Here is the code I used in the command line on the image above:
nearblack -white -o output.jpg input.jpg
Note: the –white is required because the artifacts in this particular image are white.
|and look at it now. It’s a real beaut|