How to create a moving-window on a grid

Hi, I am very new to GMT and my project requires me to create a roughness map from xyz data. I have been able to grid the data and produce digital elevation maps (DEM). From these I would like to code a 3x3 window on the grid data, find the rms of this window and allocate it to the central position.
This link describes the technique which I would like to code.

Comparison of roving-window and search-window techniques for characterising landscape morphometry - ScienceDirect

Any suggestions would be appreciated to point me in the right direction.

Hi Marem!!

Please check the link of the technique. I think it is your local PC, not in internet.

Thank you @Esteban82.
I have updated my post.

If I understand correctly and as far as I know. I think that you could use grdgdal to calculate the roughness with the arguments -Adem+mroughness. Altough, I am not sure if the function of gdal is the same that you want.

That works with a grid, so first you will have to convert your xyz data table into a grid. If your data is evenly spaced, try xyx2grd.

1 Like

I’ve done something similar to this. I used a moving window (over the grid) to implement an algorithm which assigned terrain types (valleys, peaks, slopes and flat and so on) to DEM data.

Unfortunately I’ve lost the code. But from memory I used grdfilter and grdmath. It’s easy enough to do moving window averages using grdfilter, but to do a moving window RMS you’d probably need to do a bit of manipulation of your data using grdmath.

1 Like