I'm using GDAL to warp images into a different map-projections. However the warping processes seem to leave grey marks where the boundary of the original image was (see warped.png below). I figured out this was probably caused by my image having a white background and the 'filler' pixels created by the warping process being transparent but black. And the interpolation is smudging the black and white together (even though it shouldn't as the black is transparent).

Is there any way to avoid the grey outline from appearing? Maybe force gdalwarp to fill with opaque white rather than transparent black?

I can't do a square crop on the warped image as I'll loose bits of the image, and I can't just make my background black instead of white as this messes up some filtering I have to do beforehand.

There seems to be lots of options for gdalwarp that sound useful like -srcnodata but I can't figure out how to use them.





Using the -r near flag will implement nearest-neighbor resampling. If that doesn't get rid of the border, at least it will make it pure black!

  • thanks. It turned out that the culprit was not gdalwarp but gdal2tiles (after warping I split the image into google maps tiles, then stitch them together again to check everything looks OK). I used -r near with gdal2tiles and this fixed the problem. – spiderplant0 Jan 3 '11 at 17:01

You can use the GDAL nearblack tool to make the border white.

  • thanks. I'm using whubers solution but if I need improved interpolation I'll try this on the warped TIFF before tiling. – spiderplant0 Jan 3 '11 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.