Skip to content

Commit

Permalink
Merge branch 'grass8' into i.sam2
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhite911 authored Dec 23, 2024
2 parents b769ba2 + fecefcc commit df35729
Show file tree
Hide file tree
Showing 45 changed files with 2,059 additions and 705 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
pip install -r grass-addons/.github/workflows/extra_requirements.txt
- name: Set up R
uses: r-lib/actions/setup-r@e6be4b3706e0f39bc7a4cf4496a5f2c4cb840040 # v2.10.1
uses: r-lib/actions/setup-r@473c68190595b311a74f208fba61a8d8c0d4c247 # v2.11.1
with:
r-version: 4.2.1

Expand All @@ -121,7 +121,7 @@ jobs:
../.github/workflows/test.sh
- name: Make HTML test report available
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: testreport-grass-${{ matrix.grass-version }}-python-${{ matrix.python-version }}
path: grass-addons/src/testreport
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# list of files that changed across commits
fetch-depth: 0
- name: Lint code base
uses: super-linter/super-linter@b92721f792f381cedc002ecdbb9847a15ece5bb8 # v7.1.0
uses: super-linter/super-linter@85f7611e0f7b53c8573cca84aa0ed4344f6f6a4d # v7.2.1
env:
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion src/general/g.citation/g.citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def print_bibtex(citation, output):
sep="",
file=output,
)
print(" year = {", citation["year"], "}", sep="", file=output)
print(" year = {", citation["year"], "},", sep="", file=output)
print(
" note = {Accessed: ",
citation["access"],
Expand Down
7 changes: 0 additions & 7 deletions src/imagery/i.eodag/i.eodag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,13 +1323,6 @@ def main():


if __name__ == "__main__":
gs.warning(_("Experimental Version..."))
gs.warning(
_(
"This module is still under development, \
and its behaviour is not guaranteed to be reliable"
)
)
options, flags = gs.parser()

try:
Expand Down
1 change: 0 additions & 1 deletion src/raster/r.edm.eval/r.edm.eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
from subprocess import PIPE
import grass.script as gs
from grass.pygrass.modules import Module
import pandas as pd
import random

clean_layers = []
Expand Down
2 changes: 1 addition & 1 deletion src/raster/r.fusion/r.fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def main():
exp = f"{output_map} = float({last_result})"
gscript.mapcalc(exp)
else:
gscript.run_command("g.copy", raster=f"{output_map},{last_result}")
gscript.run_command("g.copy", raster=f"{last_result},{output_map}")

# copy color rules from input to output
gscript.run_command("r.colors", map=output_map, raster=lowres_map)
Expand Down
12 changes: 5 additions & 7 deletions src/raster/r.maxent.predict/r.maxent.predict.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,9 @@ <h2>SEE ALSO</h2>

<h2>AUTHOR</h2>

Paulo van Breugel, <a href="https://ecodiv.earth">https://ecodiv.earth</a><br>

<p>
HAS green academy University of Applied Sciences<br>
<a href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a><br>
<a href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
<a href="https:ecodiv.earth">Paulo van Breugel</a>, <a
href="https://has.nl">HAS green academy</a>, <a
href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a>, <a
href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
Landscapes research group</a>
8 changes: 3 additions & 5 deletions src/raster/r.maxent.setup/r.maxent.setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ <h2>SEE ALSO</h2>

<h2>AUTHOR</h2>

Paulo van Breugel, <a href="https://ecodiv.earth">https://ecodiv.earth</a><br>

<p>
HAS green academy University of Applied Sciences<br> <a
<a href="https:ecodiv.earth">Paulo van Breugel</a>, <a
href="https://has.nl">HAS green academy</a>, <a
href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a><br> <a
Biomonitoring research group</a>, <a
href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
Landscapes research group</a>
12 changes: 5 additions & 7 deletions src/raster/r.maxent.train/r.maxent.train.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,9 @@ <h2>SEE ALSO</h2>

<h2>AUTHOR</h2>

Paulo van Breugel, <a href="https://ecodiv.earth">https://ecodiv.earth</a><br>

<p>
HAS green academy University of Applied Sciences<br>
<a href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a><br>
<a href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
<a href="https:ecodiv.earth">Paulo van Breugel</a>, <a
href="https://has.nl">HAS green academy</a>, <a
href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a>, <a
href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
Landscapes research group</a>
8 changes: 4 additions & 4 deletions src/raster/r.maxent.train/r.maxent.train.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,9 @@ def main(options, flags):
# Get list with all files in the output folder
# -----------------------------------------------------------------
all_files = all_files = os.listdir(options["outputdirectory"])
# Check if v.db.pyupdate is installed
plugins_installed = gs.read_command(
"g.extension", flags="a", quiet=function_verbosity
).split("\n")
# Create list of addons. Is later used to check if v.db.pyupdate is installed
outputs = gs.read_command("g.extension", flags="a", quiet=function_verbosity)
plugins_installed = [addon.strip() for addon in outputs.splitlines()]

# -----------------------------------------------------------------
# Import sampleprediction files(s) grass gis
Expand Down Expand Up @@ -1281,6 +1280,7 @@ def main(options, flags):
precision = options["precision"]
if precision.isdigit():
prec = 10 ** -int(precision)
prec = f"{prec:.{precision}f}"
gs.run_command(
"r.mapcalc",
expression=f"{grasslayers[idx]} = round({grasslayers[idx]}, {prec})",
Expand Down
132 changes: 75 additions & 57 deletions src/raster/r.mess/r.mess.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,62 @@
<h2>DESCRIPTION</h2>

The Multivariate Environmental Similarity (MES) surfaces was proposed
by Elith et al (2010) [1] and originally implemented in the <a
href="https://biodiversityinformatics.amnh.org/open_source/maxent/">Maxent
software</a>. The MES provides a measure of the proportional distance
of any points (in the projection data) with respect to the range of
individual covariates from the reference data. More precisely, the MES
represents how similar a point is to a reference set of points, with
respect to a set of predictor variables (V1, V2, ...). The values in
the MESS are influenced by the full distribution of the reference
points. So, sites within the environmental range of the reference
points but in relatively unusual environments will have a smaller
value than those in very common environments. See the supplementary
materials of Elith et al. (2010) [1] for more details.

<p>
<em>r.mess</em> computes the MES and the individual similarity layers
(IES - the user can select to delete these layers) and, optionally,
several other layers that help to further interpret the MES values.
<em>r.mess</em> computes the multivariate environmental similarity
(MES) [1], which measures how similar environmental conditions in one
area are to those in a reference area. This can also be used to compare
environmental conditions between current and future scenarios. See the
supplementary materials of Elith et al. (2010) [1] for more details.

<p>
Besides the MES, <em>r.mess</em> computes the individual similarity
layers (IES - the user can select to delete these layers) and,
optionally, several other layers that help to further interpret the MES
values:

<p>
<ul>
<li>the area where for at least one of the variables has a value
that falls outside the range of values found in the reference set</li>
<li>the most dissimilar variable (MoD)</li>
<li>the sum of the IES layers where IES &lt; 0. This is similar to
the NT1 measure as proposed by Mesgaran et al. 2014 [2]</li>
<li>the number of layers with negative values</li>
<li>The area where for at least one of the variables has a value
that falls outside the range of values found in the reference set.</li>
<li>The most dissimilar variable (MoD).</li>
<li>The sum of the IES layers where IES &lt; 0. This is similar to
the NT1 measure as proposed by Mesgaran et al. 2014 [2].</li>
<li>The number of layers with negative values.</li>
</ul>

<p>
The user can compare a set of reference / baseline conditions (ref) and
projected / test conditions (proj). For the reference conditions, the
whole region can be used (no reference areas or points are given).
Alternatively, one can define a set of reference/sample points
(presvect) or reference/sample areas (presrast) against which other
areas are to be compared. The projected conditions can be future
conditions in the same area (similarity across time), or conditions in
another area (similarity between two different areas). See the examples
for more details.
The user can compare a set of reference (baseline) conditions to
projected (test) conditions. The reference conditions are defined by a
set of environmental raster layers (<b>ref_env</b>). To specify the
reference area, one of the following can be used:

<h2>NOTES</h2>
<p>
<ul>
<li><b>ref_rast</b> = reference raster layer: A raster with values of 1
and 0 (or nodata). Reference conditions are derived from the locations
where the raster value is 1.</li>
<li><b>ref_vect</b> = reference vector point layer: Reference conditions
are taken for the point locations in the vector layer.</li>
<li><b>ref_region</b> = reference region: Only areas within the
specified region's boundaries are considered as the reference
area.</li>
</ul>

Note that a mask is taken into account when computing the frequency
distribution of the reference data layers, but is removed when
computing the output layers. This means that instead of using a
raster layer to delimit an reference / sample area (<i>ref_rast</i>,
see example 2), one can use the mask to delimit a reference area,
and compute how similar the areas area outside the mask.
<p>
If no reference raster map, vector map, or region is provided, the entire
area covered by the input environmental raster layers is used as the
reference area.

<p>
The projected (test) conditions are defined by a second set of
environmental variables (<b>proj_env</b>). They can represent future
conditions in the same area (similarity across time), or conditions in
another area (similarity between two different areas). If a projection
region (<b>proj_region</b>) is provided, the MESS (and other layers)
will be limited to that region.

<p>
If <b>proj_env</b> is not provided, the MESS value of a raster cell
represents how similar the conditions in that cell are compared to the
medium conditions across the whole area.

<h2>EXAMPLE</h2>

Expand All @@ -60,24 +70,24 @@ <h2>EXAMPLE</h2>

<h3>Example 1</h3>

The simplest case is when only a set of reference data layers (<i>env
</i>) is provided. The multi-variate similarity values of the resulting
The simplest case is when only a set of reference data layers (<b>ref_env
</b>) is provided. The multi-variate similarity values of the resulting
map are a measure of how similar conditions in a location are to the
median conditions in the whole region.

<p>>
<div class="code"><pre>
g.region raster=bio1
r.mess env=bio1,bio12,bio15 output=Ex_01
r.mess ref_env=bio1,bio12,bio15 output=Ex_01
</pre></div>

<p>
Thus, in the maps above, the value in each pixel represents how similar
conditions are in that pixel to the median conditions in the entire
region, in terms of mean annual temperature (bio1), mean annual
precipitation (bio12), precipitation seasonality (bio15) and the three
Thus, in the following maps, the value in each pixel represents how
similar conditions are in that pixel to the median conditions in the
entire region, in terms of mean annual temperature (bio1), mean annual
precipitation (bio12), precipitation seasonality (bio15) and the three
combined (MES).

<p>
<center>
<img src="r_mess_Ex_01.png">
</center>
Expand All @@ -93,7 +103,7 @@ <h3>Example 2</h3>
<p>
<div class="code"><pre>
g.region raster=bio1
r.mess -m -n -i env=bio1,bio12,bio15 ref_rast=ppa output=Ex_02
r.mess -m -n -i ref_env=bio1,bio12,bio15 ref_rast=ppa output=Ex_02
</pre></div>

<p>
Expand All @@ -111,16 +121,14 @@ <h3>Example 2</h3>
<h3>Example 3</h3>

Similarity between long-term average conditions based on the period
1950-2000 (<i>env</i>) and projections for climate conditions in
2070 under RCP85 based on the IPSL General Circulation Models (<i>
env_proj</i>). No reference points or areas are defined in this
example, so the whole region is used as a reference. Note that this is
equivalent to what the Maxent program does when computing the MESS
layers.
1950-2000 (<b>ref_env</b>) and projections for climate conditions in
2070 under RCP85 based on the IPSL General Circulation Models (<b>
proj_env</b>). No reference points or areas are defined in this
example, so the whole region is used as a reference.

<div class="code"><pre>
g.region raster=bio1
r.mess env=bio1,bio12,bio15 env_proj=IPSL_bio1,IPSL_bio12,IPSL_bio15
r.mess ref_env=bio1,bio12,bio15 proj_env=IPSL_bio1,IPSL_bio12,IPSL_bio15
output=Ex_03
</pre></div>

Expand All @@ -135,6 +143,7 @@ <h3>Example 3</h3>
MES of more than one variable is negative (dark gray areas in the
<i>Count</i> map).

<p>
<center>
<img src="r_mess_Ex_03.png">
</center>
Expand All @@ -157,7 +166,16 @@ <h2>REFERENCES</h2>
M. 2015. Environmental Gap Analysis to Prioritize Conservation Efforts
in Eastern Africa. PLoS ONE 10: e0121444.

<h2>SEE ALSO</h2>

For an example of using the <em>r.mess</em> addon as part of a modeling
workflow, see the tutorial <a
href="https://ecodiv.earth/TutorialsNotes/sdmingrassgis/">Species
distribution modeling using Maxent in GRASS GIS</a>.


<h2>AUTHOR</h2>

Paulo van Breugel, paulo at ecodiv.earth
Paulo van Breugel, <a href="https://ecodiv.earth">https://ecodiv.earth</a> | HAS green academy University of Applied Sciences | <a href="https://www.has.nl/en/research/professorships/innovative-bio-monitoring-professorship/">Innovative
Biomonitoring research group</a> | <a href="https://www.has.nl/en/research/professorships/climate-robust-landscapes-professorship/">Climate-robust
Landscapes research group</a>
Loading

0 comments on commit df35729

Please sign in to comment.