wschwanghart / topotoolbox

A MATLAB software for the analysis of digital elevation models -
https://topotoolbox.wordpress.com/
153 stars 89 forks source link

Implementation of Meltons ruggedness in GRIDobj\roughness is incorrect #23

Closed kerryleith closed 1 year ago

kerryleith commented 2 years ago

Meltons ruggedness value should reflect the maximum catchment relief / catchment area^0.5 rather than the local relief / area^0.5 as is currently implemented.

Finding the max catchment relief in topotoolbox is doing my head in, but there's an implementation for SAGA here: https://sourceforge.net/p/saga-gis/code/ci/master/tree/saga-gis/src/tools/terrain_analysis/ta_hydrology/melton_ruggedness.cpp#l23

FYI, a work-around using SAGA GIS via Matlab in windows:

%save grid to temporary file GRIDobj2geotiff(DEM,'temp.tif'); %path to SAGA gis files (NOT QGIS installed version) exepath = 'C:\saga-8.2.2_x64\'; %convert to saga grid, run Meltons ratio tool, convert back to tif, and replace .tfw file system(sprintf('%s%s%s%s%s%s', exepath,'saga_cmd io_gdal 0',' -FILES:', 'temp.tif',' -GRIDS:', 'temp.sgrd')) system(sprintf('%s%s%s%s%s%s', exepath,'saga_cmd ta_hydrology 23',' -DEM:', 'temp.sgrd',' -MRN:', 'mrn.sgrd')) system(sprintf('%s%s%s%s%s%s%s%s', exepath,'saga_cmd io_gdal 1',' -GRIDS:', 'mrn.sgrd', ' -FILE:', 'mrn.tif', ' -FORMAT:', 'GeoTIFF')) movefile('temp.tfw', 'mrn.tfw'); mrn = GRIDobj('mrn.tif');
imageschs(DEM,mrn, 'caxis', [0 16])

delete('temp.tif', 'temp.sgrd', 'temp.sdat', 'temp.prj', 'temp.mgrd') delete('mrn.tif', 'mrn.tfw', 'mrn.sgrd', 'mrn.sdat', 'mrn.prj', 'mrn.mgrd')

wschwanghart commented 1 year ago

Thanks Kerry, and sorry that it took a while to answer. Now, there is a new function to calculate Melton's ruggedness. Cheers, Wolfgang