Skip to content

Commit

Permalink
v.maxent.swd: update manual page, added option to thin point layers a…
Browse files Browse the repository at this point in the history
…nd bugfixes (#1022)

- Included an example
- Added option to thin species presence and background point layers.
- Bug fixes

Co-authored-by: Markus Neteler <neteler@osgeo.org>
  • Loading branch information
ecodiv and neteler committed Feb 12, 2024
1 parent 19b7907 commit 92c4614
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 79 deletions.
168 changes: 115 additions & 53 deletions src/vector/v.maxent.swd/v.maxent.swd.html
Original file line number Diff line number Diff line change
@@ -1,97 +1,159 @@
<h2>DESCRIPTION</h2>

<em>v.maxent.swd</em> Produce a set of SWD files as input to MaxEnt
3.3.3k+, based on a point vector layer(s) of species distribution(s), a
point layer with background points and user-defined raster layers. The
user can also let the function create the background point file.
(respecting region and mask, if set).
The <em>v.maxent.swd</em> takes one or more point vector layers with
the location of species presence locations (parameter: <b>species</b>),
and a set of raster layers representing relevant environmental
variables (parameter: <b>evp_maps</b>). For all point locations, it
reads in the values of the environmental raster layers. The resulting
point layers(s) are combined in one layer and this is exported as a SWD
file that can be used as input for MaxEnd 3.4 or higher.

<p>
The SWD file format is a simple CSV-like file format as described
in Elith et al. 2011. The first three fields provide the species name,
x-coordinate and y-coordinate, while subsequent fields contain the
values of the user-selected environmental parameters. Note that the
coordinates are not used by the MaxEnt program if all environmental
data is given in the SWD format file.

<p>
The user can provide one or more species point files, which will be
combined in one SWD file. The map names of both the species point
layers and the environmental parameters can be replaced by alias names,
which will be used by MaxEnt.
The user can also provide a point layer with background points
(parameter: <b>bgp</b>). Alternatively, a user-defined number of
background points can be generated automatically, respecting the
computational region and MASK. In either case, for all point locations,
the function reads in the values of the environmental raster layers.
The resulting point layer is exported as a SWD file.

<p>
If alias names are used, a CSV file (alias_file) can be created with
alias names in the first column and map names in the second column,
separated by comma, without header. This can be used as input in
r.maxent.lambdas (but note that this addon does not seem to work with
outputs from Maxent 3.4+).
separated by comma, without a header.

<h2>NOTES</h2>

The SWD output files are simple comma delimited text
files (.csv) and can therefore be easily read in in for example R
and subsequently used in other models / functions.
The map names of both the species point layers and the environmental
parameters can be replaced by alias names, which will be used by
MaxEnt.

<p>
Maxent expects the raster cells to be perfectly square. I.e., the n-s
and e-w resolution need to be the same. v.maxent.swd will fail if this
is not the case. If this happens, you should change the resolution.
The SWD file format is a simple comma-delimited text files. The first
three fields provide the species name, x-coordinate and y-coordinate,
while subsequent fields contain the values of the user-selected
environmental parameters. The files can be easily read in for example,
R and subsequently used in other models / functions.

<p>
Following the grass gis convention, the resolution of an exported
raster is determined by the region settings. So make sure to set the
resolution of the region so that the n-s and e-w resolution match. To
accomplish this, you can use (replaced the *** for the desired
resolution):
Maxent expects the n-s and e-w resolution to be the same. Following the
grass gis convention, the resolution of an exported raster is
determined by the region settings. So make sure to set the resolution
of the region so that the n-s and e-w resolution match. To accomplish
this, you can use (replaced the *** for the desired resolution):

<div class="code"><pre>
g.region -a res=***
</pre></div>

<p>
Alternatively, you can set the <i>-e flag</i>. This will run g.region
Alternatively, you can set the <b>-e flag</b>. This will run g.region
for you, adjusting the resolution so both the ns and ew resolutionn
match the smallest of the two, using nearest neighbor resampling.

<p>
This addon is a vector based alternative to <em>r.out.maxent_swd</em>.
This addon is a vector-based alternative to <em>r.out.maxent_swd</em>.
It can be more efficient with sparse data points. The main difference
is that with this addon you can have more than one sample point per
raster cell. points per raster cell. If this is not desired, use
r.out.maxent_swd. Another difference is the option to export the
predictor raster layers to a user-defined folder. This can be used in
Maxent, Maxnet addon for R or other software.
raster cell. But note that you can use the <b>-t</b> flag to thin the
point layer so that there is never more than 1 point per raster cell.
Another difference is the option to export the predictor raster layers
to a user-defined folder. This can be used in Maxent, Maxnet addon for
R or other software.

<h2>EXAMPLES</h2>

The examples below use a dataset that you can download <a
href="https://ecodiv.earth/share/reader_SDM/grassmaxent_sampledata.zip">from
here</a>. It includes <a href="">vector point layer</a> with
observation locations of the pale-throated sloth (<i>Bradypus
tridactylus</i>) from <a
href="https://doi.org/10.15468/dl.br8b4a">GBIF</a>, a number of bioclim
raster layers from <a
href="https://www.worldclim.org/data/worldclim21.html">WorldClim</a>,
the <a href="https://www.iucnredlist.org/species/3037/210442660">IUCN
RedList range map</a> of the species, and a boundary layer of the South
American countries from <a
href="https://www.naturalearthdata.com/downloads/50m-cultural-vectors/">NaturalEarth</a>.

<p>
The zip file contains a <a
href="https://grass.osgeo.org/grass-stable/manuals/grass_database.html#grass-locations">GRASS
location</a>. Unzip it and put it in a GRASS GIS database. Next, open
GRASS GIS and go to the mapset <i>southamerica</i>. Download the zip
file, and unzip it in a GRASS GIS database.

<div class="code">
<pre>
v.maxent.swd -t species=Bradypus_tridactylus \
evp_maps=bio02,bio03@southamerica,bio08,bio09,bio13,bio15,bio17 \
evp_cat=sa_eco_l2 alias_cat=landuse nbgp=10000 \
bgr_output=maxentinput/bgrd_swd.csv \
species_output=maxentinput/spec_swd.csv \
export_rasters=maxentinput/envlayers
</pre>
</div>

<p>
The output is a folder <i>maxentinput</i> with the SWD files
bgrd_swd.csv and spec_swd.csv and the accompanying proj files. The
latter provide information about the CRS, which might be useful if you
want to import the point layers in another software tools. In addition,
the example code creates the raster layers of the environmental layes
in ascii format in the folder <i>envlayers</i>.

<p>
The created data layers can be used as input for <a
href="http://biodiversityinformatics.amnh.org/open_source/maxent/">Maxent</a>.
Alternatively, you can use it as input for the <em>r.maxent.train</em>
addon, which provides a convenient wrapper for the <i>Maxent</i>
software.

<h2>SEE ALSO</h2>

<ul>
<li>MaxEnt 3.4.1 (<a
href="http://biodiversityinformatics.amnh.org/open_source/maxent/">
http://biodiversityinformatics.amnh.org/open_source/maxent/</a>)</li>
<li><a href="r.out.maxent_swd.html">r.out.maxent_swd</a>, the original
implementation using species distribution data in raster format.</li>
<li><a href="r.maxent.lambdas.html">r.maxent.lambdas</a> addon to
compute raw or logistic prediction maps from MaxEnt lambdas files.</li>
<li><a href="r.maxent.train.html">r.maxent.train</a> addon to
create/train a Maxent model. The addon provides a wrapper to the
Maxent software.</li>

<li><a href="r.out.maxent_swd.html">r.out.maxent_swd</a>, an
alternative implementation of this addon, using species
distribution data in raster format.</li>

<li><a href="r.maxent.lambdas.html">r.maxent.lambdas</a> addon to
compute raw or logistic prediction maps from MaxEnt lambdas
files.</li>
</ul>

<h2>REFERENCES</h2>

<ul>
<li> Steven J. Phillips, Miroslav Dudík, Robert E. Schapire.A
<li>MaxEnt 3.4.1 (<a
href="http://biodiversityinformatics.amnh.org/open_source/maxent/">
http://biodiversityinformatics.amnh.org/open_source/maxent</a>)</li>
<li> Steven J. Phillips, Miroslav Dudík, Robert E. Schapire. A
maximum entropy approach to species distribution modeling. In
Proceedings of the Twenty-First International Conference on Machine
Learning, pages 655-662, 2004.</li>
<li>Steven J. Phillips, Robert
P. Anderson, Robert E. Schapire. Maximum entropy modeling of
species geographic distributions. Ecological Modelling,
190:231-259, 2006.</li>
<li>Jane Elith, Steven J. Phillips, Trevor
Hastie, Miroslav Dudík, Yung En Chee, Colin J. Yates. A statistical
explanation of MaxEnt for ecologists. Diversity and Distributions,
17:43-57, 2011. </li>
<li>Steven J. Phillips, Robert P. Anderson, Robert E. Schapire.
Maximum entropy modeling of species geographic distributions.
Ecological Modelling, 190:231-259, 2006.</li>
<li>Jane Elith, Steven J. Phillips, Trevor Hastie, Miroslav Dudík,
Yung En Chee, Colin J. Yates. A statistical explanation of MaxEnt
for ecologists. Diversity and Distributions, 17:43-57, 2011. </li>
<li>GBIF.org (12 November 2023) GBIF Occurrence Download
https://doi.org/10.15468/dl.br8b4a </li>
</ul>

<h2>AUTHOR</h2>

Paulo van Breugel, paulo at ecodiv.earth

<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
Landscapes research group</a>

0 comments on commit 92c4614

Please sign in to comment.