I am looking for a way to antialias integer DEM data (hgt file) to float GeoTIFF. That way I want to avoid gdaldem hillshade artefact lines which you can see in this picture:

enter image description here

I don't want to blur DEM data to keep the result sharp. I am actually looking for a tool to interpolate pixels in the following (or better) way. For simplicity the illustration uses only 1D, not 2D:

enter image description here

Edit: Adding image for elevation changing its direction. Input is blue (pen), output is dashed gray (pencil):

enter image description here

I bet that somebody has already invented such algorithm ;-). I am "only" looking for a tool that implements it.

Regarding 2D, algorithm would be applied in both directions and result would be average of it.

  • The thing you are suggesting is difficult because the column '1' takes into account column '0' and '2'. Thus only the first order neighbors. The middle '3' takes into account the 2nd order neighbors as well. What I guess you are looking for is the spatial average. – LMB Mar 10 '19 at 12:58

I've created a tool with the described algorithm.

The result (animating original / aliased DEM data):

enter image description here

Note that noisy DEM data (eg. NASA SRTM 1 arc-second Global) doesn't have this problem. They are "just" noisy ;-).


It looks like you are in need of focal statistics such as the average. Assuming you are using GDAL Running a Focal Mean explains that you will have to use gdal_calc.py to write your own focal function. For the goal you have I think the average should do just fine.

  • Averaging would blur the DEM data (even though only slightly). From data like 1 1 1 1 1 2 2 2 2 2 it will make 1 1 1 1.5 2 2 2 2. I actually want 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4... but from 1 2 3 5 8 7 6 I want it to stay unmodified. That's what my alg. would do. So it is still "focal statistics" but operating on adaptive neighbourhood size (area of all points of the same value + adjanced one with different value). – Martin Ždila Mar 10 '19 at 13:26
  • Right, than is that not the answer to your own question? As far as i'm aware there is no tool to do that 'out of the box'. So scripting it via gdal_calc.py seems like the logical choice? Are you skilled in python scripting? – LMB Mar 10 '19 at 13:49
  • I'll wait a bit more so maybe someone would know an naswer. If not then I may try to create such tool but probably with node-gdal (NodeJS) as I am not much into python. But I'll be wondering that there is no tool for this common problem ;-). Thanks anyway. – Martin Ždila Mar 10 '19 at 13:55
  • How should it behave in the case of 2 2 1 1 1 1 2 2? Perhaps on the middle of each 'patch' of equal height you could create an x,y coordinate with the height of that patch. Next you could do linear interpolation from those points to give you the result? Perhaps faster than a focal statistics approach? – LMB Mar 10 '19 at 13:55
  • Thanks for pointing out 2 2 1 1 1 1 2 2 case. I know the solution but it will be better expressed with drawing which I'll add to the question later. – Martin Ždila Mar 10 '19 at 13:59

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.