By Martin Ždila

2019-03-10 12:38:53 8 Comments

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.


@Martin Ždila 2019-03-10 21:36:06

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 ;-).

@LMB 2019-03-10 13:00:53

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 to write your own focal function. For the goal you have I think the average should do just fine.

@Martin Ždila 2019-03-10 13:26:02

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).

@LMB 2019-03-10 13:49:27

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 seems like the logical choice? Are you skilled in python scripting?

@Martin Ždila 2019-03-10 13:55:01

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.

@LMB 2019-03-10 13:55:01

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?

@Martin Ždila 2019-03-10 13:59:35

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 2019-03-10 14:13:06

@LBM please check added picture.

@LMB 2019-03-10 17:35:11

It is clear to me now. Unfortunately I have not run across this case before. It is interesting, but I know of no ready solution. But perhaps someone else will.

Related Questions

Sponsored Content

1 Answered Questions

PNG driver chokes on raster gdal_transformed to ot byte

0 Answered Questions

Copy Raster for a Raster Mosiac with Function produces corrupted data

0 Answered Questions

Rasterio Raster merge - horrible result

1 Answered Questions

1 Answered Questions

[SOLVED] Options for generalizing raster?

1 Answered Questions

[SOLVED] Mosaic to new raster

2 Answered Questions

[SOLVED] Update raster pixels on a DEM

2 Answered Questions

1 Answered Questions

Raster Smoothing python

3 Answered Questions

[SOLVED] Creating raster or vector raster from DEM point file?

Sponsored Content