From 42c4ea65b0e4aceaa7e05da9041405a2a9170035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20de=20Sousa?= Date: Mon, 17 Jul 2023 15:01:03 +0200 Subject: [PATCH] r.mblend: update for GRASS 8 (#910) * takes into account new behaviour in v.what.rast (inner buffer applied to region boundary) * updates documentation with reference to new GitHub addons repository * version number bumped to 1.2.0 --- src/raster/r.mblend/VERSION.md | 2 +- src/raster/r.mblend/r.mblend.html | 27 ++++++++++++++++++++------- src/raster/r.mblend/r.mblend.py | 23 +++++++++++++++++------ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/raster/r.mblend/VERSION.md b/src/raster/r.mblend/VERSION.md index 4e8ab91ab0..66977305e9 100644 --- a/src/raster/r.mblend/VERSION.md +++ b/src/raster/r.mblend/VERSION.md @@ -1,3 +1,3 @@ # VERSION -1.1.1 +1.2.0 diff --git a/src/raster/r.mblend/r.mblend.html b/src/raster/r.mblend/r.mblend.html index 370ffd6f59..711f697576 100644 --- a/src/raster/r.mblend/r.mblend.html +++ b/src/raster/r.mblend/r.mblend.html @@ -1,18 +1,35 @@

DESCRIPTION

-This module implements Mblend, a DEM merging method proposed by Leitão et al. (2016). It deals with cases where a study area is only partially covered by a high resolution DEM, with a coarser DEM available for the remainder (as in the case shown below). r.mblend merges the two DEMs, producing a smooth transition from the high resolution DEM to the low resolution DEM.

+This module implements Mblend, a DEM merging method proposed by Leitão +et al. (2016). It deals with cases where a study area is only partially +covered by a high resolution DEM, with a coarser DEM available for the +remainder (as in the case shown below). r.mblend merges the two DEMs, +producing a smooth transition from the high resolution DEM to the low +resolution DEM.



-The module works by identifying the edge between the two rasters (near edge, shown in read below) and the edge composed by the cells in the low resolution DEM farther away from the high resolution raster (far edge, shown in blue below). To each point along the near edge is assigned the difference between the two DEMs. To each point in the far edge is assigned the value 0. The Inverse Distance Weighted (IDW) method is then used to interpolate a new raster with the points along the two edges. This differences raster thus trends from the full difference at the near edge towards zero at the far edge.

+The module works by identifying the edge between the two rasters (near edge, +shown in read below) and the edge composed by the cells in the low resolution +DEM farther away from the high resolution raster (far edge, shown in blue +below). To each point along the near edge is assigned the difference between +the two DEMs. To each point in the far edge is assigned the value 0. The +Inverse Distance Weighted (IDW) method is then used to interpolate a new raster +with the points along the two edges. This interpolated differences raster thus +trends from the full difference at the near edge towards zero at the far edge. +



-The differences raster is finally added to the low resolution DEM given as input. In the resulting DEM, cells along the near edge take the values in the high resolution raster. The farther away from the near edge (and closer to to the far edge) the closer is their value is to the low resolution raster, producing a smooth transition, without artefacts.

+The differences raster is finally added to the low resolution DEM given as +input. In the resulting DEM, cells along the near edge take the values in the +high resolution raster. The farther away from the near edge (and closer to to +the far edge) the closer is their value is to the low resolution raster, +producing a smooth transition, without artefacts.

@@ -41,10 +58,6 @@

REFERENCES

J.P. Leitão, D. Prodanovic, C. Maksimovic, Improving merge methods for grid-based digital elevation models, Computers & Geosciences, Volume 88, March 2016, Pages 115-131, ISSN 0098-3004, DOI: 10.1016/j.cageo.2016.01.001. -

SEE ALSO

- -To report bugs, propose new features or discuss the funcioning of this add-on, visit the project repository at GitHub. -

AUTHORS

Luís Moreira de Sousa
diff --git a/src/raster/r.mblend/r.mblend.py b/src/raster/r.mblend/r.mblend.py index 947d6aea38..b69f0e063c 100755 --- a/src/raster/r.mblend/r.mblend.py +++ b/src/raster/r.mblend/r.mblend.py @@ -27,17 +27,18 @@ # %end # %option LOW # % key: low -# % description: Low resolution input raster. +# % label: Low resolution input raster. # %end # %option OUTPUT # % key: output -# % description: Name of output raster. +# % label: Name of output raster. # %end # %option FAR_EDGE # % key: far_edge # % key_desc: value # % type: double -# % description: Percentage of distance to high resolution raster used to determine far edge. Number between 0 and 100. +# % label: Percentage of distance to high resolution raster used to determine far edge. Number between 0 and 100. +# % description: When the blending occurs along a single edge a number closer to 100 tends to produce more even results. With more blending edges (e.g. high resolution DEM sits on the middle of the low resolution DEM) a lower number may produce a more regular blend. # % answer: 95 # % multiple: no # % required: no @@ -46,14 +47,15 @@ # % key: inter_points # % key_desc: value # % type: integer -# % description: Number of points to use in interpolation. A higher number produces a smoother result but requires a lengthier computation. +# % label: Number of points to use in interpolation. +# % description: A higher number produces a smoother result but requires a lengthier computation. # % answer: 50 # % multiple: no # % required: no # %end # %flag # % key: a -# % description: Assign the average difference between the two rasters to the far edge (instead of zero). +# % label: Assign the average difference between the two rasters to the far edge (instead of zero). # %end import os @@ -214,6 +216,7 @@ def main(): # Get points in low resolution farther away from high resolution raster dist_high = getTemporaryIdentifier() weights = getTemporaryIdentifier() + interpol_area_inner_buff = getTemporaryIdentifier() interpol_area_points = getTemporaryIdentifier() pre_interpol_area_points = getTemporaryIdentifier() weight_points = getTemporaryIdentifier() @@ -232,9 +235,17 @@ def main(): gscript.message( _("[r.mblend] Extract points from interpolation area " + "boundary") ) + inner_buff = -cell_side / 2 gscript.run_command( - "v.to.points", + "v.buffer", input=interpol_area, + output=interpol_area_inner_buff, + type="area", + distance=inner_buff, + ) + gscript.run_command( + "v.to.points", + input=interpol_area_inner_buff, output=pre_interpol_area_points, type="boundary", dmax=d_max,