I am using GDAL in C++ for upsampling land-cover raster data. When upsampling, I would like to smooth out the edges, so that I do not get aliased stairs but nice diagonal lines.

Essentially, the "After" image of "Results with gdalwarp cubic spline" here: Smoothing/reinterpolating raster with GDAL? is exactly what I want.

However, I cannot figure out how it was done. When I use cubic spline for interpolation, I don't get discrete values in the output - the algorithm blends between colors instead of sticking to the existing IDs.

I have also tried other interpolation methods. Nearest neighbor of course does stick with discrete values, but results in aliasing. Other options such as MODE, MIN, MAX don't seem to offer an improvement when upscaling.

Setting the color interpretation to GDALColorInterp::GCI_PaletteIndex didn't seem to change anything either - I assumed that might tell GDAL to handle it as discrete data. Does the raster data itself need to satisfy any specific requirements for this to work as intended?

Your Answer

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

Browse other questions tagged or ask your own question.