Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix_few_typos
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacata authored Oct 30, 2024
2 parents 82b326e + b27f2df commit 5879a18
Show file tree
Hide file tree
Showing 10 changed files with 893 additions and 47 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions r.slopeunits.clean/r.slopeunits.clean.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
<h2>DESCRIPTION</h2>
<em>r.slopeunits.clean</em> cleans slope units layer, e.g. results of <em>r.slopeunits.create</em>.

<h2>NOTES</h2>

<h2>EXAMPLE</h2>

<div class="code"><pre>
r.slopeunits.clean \
demmap=dem_italia_isolegrandi@su_test \
plainsmap=flat \
slumap=su_tmp \
slumapclean=su_tmp_cl \
cleansize=25000 \
-m
</pre></div>

<h2>SEE ALSO</h2>
<em>
<a href="r.slopeunits.create.html">r.slopeunits.create</a>,
<a href="r.slopeunits.metrics.html">r.slopeunits.metrics</a>,
<a href="r.slopeunits.optimize.html">r.slopeunits.optimize</a>
</em>

<h2>AUTHORS</h2>
Main authors: Ivan Marchesini, Massimiliano Alvioli, CNR-IRPI
<br>
Markus Metz (refactoring, translation of "clean_method_3" to python), Carmen Tawalika (creation of extra addon), <a href="https://www.mundialis.de/">mundialis</a>
16 changes: 9 additions & 7 deletions r.slopeunits.clean/r.slopeunits.clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#
############################################################################
#
# MODULE: r.slopeunits.clean for GRASS 7
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli
# MODULE: r.slopeunits.clean for GRASS 8
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli, Markus Metz
# (Refactoring, partly translation to python), Carmen Tawalika
# (creation of extra addon)
# PURPOSE: Clean slope units layer
# COPYRIGHT: (C) 2004-2012 by the GRASS Development Team
# COPYRIGHT: (C) 2004-2024 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand All @@ -23,25 +25,25 @@
# %option G_OPT_R_INPUT
# % key: demmap
# % description: Input digital elevation model
# % required : yes
# % required: yes
# %end

# %option G_OPT_R_INPUT
# % key: plainsmap
# % description: Input raster map of alluvial plains
# % required : no
# % required: no
# %end

# %option G_OPT_R_OUTPUT
# % key: slumap
# % description: Output Slope Units layer (the main output)
# % required : yes
# % required: yes
# %end

# %option G_OPT_R_OUTPUT
# % key: slumapclean
# % description: Output Slope Units layer, cleaned (the main output)
# % required : no
# % required: no
# %end

# %option
Expand Down
21 changes: 21 additions & 0 deletions r.slopeunits.create/r.slopeunits.create.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
<h2>DESCRIPTION</h2>
<em>r.slopeunits.create</em> creates a raster layer of slope units. Optionally, a vector map can be created.

<h2>NOTES</h2>

<h2>EXAMPLE</h2>

<div class="code"><pre>
r.slopeunits.create \
demmap=dem_italia_isolegrandi@su_test \
plainsmap=flat \
slumap=su_tmp \
thresh=250000 \
areamin=200000 \
cvmin=0.25 \
rf=2 \
maxiteration=50
</pre></div>

<h2>SEE ALSO</h2>
<em>
<a href="r.slopeunits.clean.html">r.slopeunits.clean</a>,
<a href="r.slopeunits.metrics.html">r.slopeunits.metrics</a>,
<a href="r.slopeunits.optimize.html">r.slopeunits.optimize</a>
</em>

<h2>AUTHORS</h2>
Main authors: Ivan Marchesini, Massimiliano Alvioli, CNR-IRPI
<br>
Markus Metz (refactoring), <a href="https://www.mundialis.de/">mundialis</a>
71 changes: 57 additions & 14 deletions r.slopeunits.create/r.slopeunits.create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
############################################################################
#
# MODULE: r.slopeunits.create for GRASS 7
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli
# MODULE: r.slopeunits.create for GRASS 8
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli, Markus Metz (Refactoring)
# PURPOSE: To create a raster layer of slope units
# COPYRIGHT: (C) 2004-2012 by the GRASS Development Team
# COPYRIGHT: (C) 2004-2024 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand All @@ -23,73 +23,97 @@
# %option G_OPT_R_INPUT
# % key: demmap
# % description: Input digital elevation model
# % required : yes
# % required: yes
# %end

# %option G_OPT_R_INPUT
# % key: plainsmap
# % description: Input raster map of alluvial plains
# % required : no
# % required: no
# %end

# %option G_OPT_R_OUTPUT
# % key: slumap
# % description: Output Slope Units layer (the main output)
# % required : yes
# % required: yes
# %end

# %option G_OPT_V_OUTPUT
# % key: slumapvect
# % description: Output Slope Units layer as vector layer
# % required: no
# %end

# %option G_OPT_R_OUTPUT
# % key: circvarmap
# % description: Output Circular Variance layer
# % required : no
# % required: no
# %end

# %option G_OPT_R_OUTPUT
# % key: areamap
# % description: Output Area layer; values in square meters
# % required : no
# % required: no
# %end

# %option
# % key: thresh
# % type: double
# % description: Initial threshold (m^2).
# % required : yes
# % required: yes
# %end

# %option
# % key: areamin
# % type: double
# % description: Minimum area (m^2) below which the slope unit is not further segmented
# % required : yes
# % required: yes
# %end

# %option
# % key: areamax
# % type: double
# % description: Maximum area (m^2) above which the slope unit is segmented irrespective of aspect
# % required : no
# % required: no
# %end

# %option
# % key: cvmin
# % type: double
# % description: Minimum value of the circular variance (0.0-1.0) below which the slope unit is not further segmented
# % required : yes
# % required: yes
# %end

# %option
# % key: rf
# % type: integer
# % description: Factor used to iterativelly reduce initial threshold: newthresh=thresh-thresh/reductionfactor
# % required : yes
# % required: yes
# %end

# %option
# % key: maxiteration
# % type: integer
# % description: maximum number of iteration to do before the procedure is in any case stopped
# % required : yes
# % required: yes
# %end

# %option
# % key: generalize_treshold
# % type: double
# % description: Threshold for maximal tolerance value for v.generalize
# % options: 0-1000000000
# % answer: 20
# %end

# %flag
# % key: g
# % description: Generalize Slope Units vector layer
# % guisection: flags
# %end

# %rules
# % required: g,slumapvect
# %end

import atexit
Expand Down Expand Up @@ -700,6 +724,22 @@ def slope_units(
grass.message("Slope units calculated.")


def export_as_vect(slumap, slumapvect):
"""Create vector map from raster map"""
grass.run_command(
"r.to.vect", type="area", input=slumap, output=slumapvect
)
threshold = options["generalize_treshold"]
if flags["g"]:
grass.run_command(
"v.generalize",
input=slumapvect,
output=f"{slumapvect}_gen",
method="douglas",
threshold=threshold,
)


def main():
"""Main function of r.slopeunits"""
global rm_rasters, rm_vectors
Expand Down Expand Up @@ -730,6 +770,9 @@ def main():
red,
maxiter,
)
if options["slumapvect"]:
export_as_vect(slumap, options["slumapvect"])

grass.message("Slope units finished.")


Expand Down
38 changes: 34 additions & 4 deletions r.slopeunits.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
<h2>DESCRIPTION</h2>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>r.slopeunits toolset - GRASS GIS manual</title>
<meta name="Author" content="Ivan Marchesini, Massimiliano Alvioli, mundialis team">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="en-us">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body bgcolor="white">
<div id="container">

<a href="https://grass.osgeo.org/grass-stable/manuals/index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">

<h2>NAME</h2>

<h2>NOTES</h2>
<em>r.slopeunits</em> is a GRASS GIS addon toolset that creates, cleans
and calculate metrics for slope units. Additionally, optimal input values can
be determined.

<h2>EXAMPLE</h2>
<h2>KEYWORDS</h2>

<h2>DESCRIPTION</h2>
The <em>r.slopeunits</em> toolset consists of currently four modules:

<h2>SEE ALSO</h2>
<ul>
<li><a href="r.slopeunits.create.html">r.slopeunits.create</a>: Creates a raster layer of slope units. Optionally, a vector map can be created.</li>
<li><a href="r.slopeunits.clean.html">r.slopeunits.clean</a>: Cleans slope units layer, e.g. results of r.slopeunits.create.</li>
<li><a href="r.slopeunits.metrics.html">r.slopeunits.metrics</a>: Creates metrics for slope units.</li>
<li><a href="r.slopeunits.optimize.html">r.slopeunits.optimize</a>: Determines optimal input values for slope units.</li>
</ul>

<h2>AUTHORS</h2>
Main authors: Ivan Marchesini, Massimiliano Alvioli, CNR-IRPI
<br>
Markus Metz (translation to python, refactoring), Carmen Tawalika (translation to python, refactoring),
<a href="https://www.mundialis.de/">mundialis</a>
22 changes: 22 additions & 0 deletions r.slopeunits.metrics/r.slopeunits.metrics.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
<h2>DESCRIPTION</h2>
<em>r.slopeunits.metrics</em> creates metrics for slope units. Returns
output "areamin, cvmin, v_fin and i_fin" to stdout, optionally writes to a file.

<h2>NOTES</h2>

<h2>EXAMPLE</h2>

<div class="code"><pre>
r.slopeunits.metrics \
basin=basin_chk \
demmap=dem_italia_isolegrandi@su_test \
slumapclean=su_tmp_cl \
cleansize=25000 \
areamin=50000.0 \
cvmin=0.05 \
resolution=625 \
outfile=objf_1.dat
</pre></div>

<h2>SEE ALSO</h2>
<em>
<a href="r.slopeunits.create.html">r.slopeunits.create</a>,
<a href="r.slopeunits.clean.html">r.slopeunits.clean</a>,
<a href="r.slopeunits.optimize.html">r.slopeunits.optimize</a>
</em>

<h2>AUTHORS</h2>
Main authors: Ivan Marchesini, Massimiliano Alvioli, CNR-IRPI
<br>
Carmen Tawalika (translation to python), <a href="https://www.mundialis.de/">mundialis</a>
17 changes: 9 additions & 8 deletions r.slopeunits.metrics/r.slopeunits.metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
############################################################################
#
# MODULE: r.slopeunits.metrics for GRASS 8
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli
# PURPOSE: To create a raster layer of slope units
# AUTHOR(S): Ivan Marchesini, Massimiliano Alvioli, Carmen Tawalika
# (Translation to python)
# PURPOSE: Create metrics for slope units
# COPYRIGHT: (C) 2004-2024 by the GRASS Development Team
#
# This program is free software under the GNU General Public
Expand All @@ -29,13 +30,13 @@
# %option G_OPT_R_INPUT
# % key: demmap
# % description: Input digital elevation model
# % required : yes
# % required: yes
# %end

# %option G_OPT_R_OUTPUT
# % key: slumapclean
# % description: Output Slope Units layer, cleaned (the main output)
# % required : yes
# % required: yes
# %end

# %option
Expand All @@ -50,27 +51,27 @@
# % key: areamin
# % type: double
# % description: Minimum area (m^2) below which the slope unit is not further segmented
# % required : yes
# % required: yes
# %end

# %option
# % key: cvmin
# % type: double
# % description: Minimum value of the circular variance (0.0-1.0) below which the slope unit is not further segmented
# % required : yes
# % required: yes
# %end

# %option
# % key: resolution
# % type: double
# % description: Resolution
# % required : yes
# % required: yes
# %end

# %option G_OPT_F_OUTPUT
# % key: outfile
# % description: Output file with metrics
# % required : no
# % required: no
# %end

import atexit
Expand Down
Loading

0 comments on commit 5879a18

Please sign in to comment.