Skip to content

v.maxent.swd

Export raster values at given point locations as text file in SWD format for input in Maxent. In addition, the addon can export the environmental raster layers as ascii files.

v.maxent.swd [-teh] [species=string [,string,...]] [species_name=string] evp_maps=string [,string,...] [alias_names=string] [evp_cat=string [,string,...]] [alias_cat=string] [nbgp=number] [bgp=string] [species_output=name] [bgr_output=name] [alias_output=name] [export_rasters=name] [format=string] [nodata=number] [seed=integer] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.maxent.swd evp_maps=string

grass.script.run_command("v.maxent.swd", species=None, species_name=None, evp_maps, alias_names=None, evp_cat=None, alias_cat=None, nbgp=None, bgp=None, species_output=None, bgr_output=None, alias_output=None, export_rasters=None, format=None, nodata=-9999, seed=1, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("v.maxent.swd", evp_maps="string")

Parameters

species=string [,string,...]
    vector map(s) of species occurence
species_name=string
    Alias-name(s) for species (default: map names).
evp_maps=string [,string,...] [required]
    Environmental parameter map(s)
alias_names=string
    Alias names for environmental parameter(s)
evp_cat=string [,string,...]
    Categorial environmental parameter map(s)
alias_cat=string
    Alias names for categorial parameter(s)
nbgp=number
    Number or percentage of background points
bgp=string
    Vector layer with background / absence points
species_output=name
    Species SWD file
bgr_output=name
    Background SWD file
alias_output=name
    CSV file with alias and map names
export_rasters=name
    Folder where to export the predictor raster layers to
format=string
    Raster data format to write (case sensitive, see r.out.gdal)
    Allowed values: ascii, GeoTIFF
nodata=number
    nodata value in output files
    Default: -9999
seed=integer
    Seed for generating random points
    Default: 1
-t
    Thin species and background points
    Select this flag if you want to limit the species and background points to maximum one point per raster cell. Note that this is already the case for the background points with the nbgp option.
-e
    Automatically adapt resolution
    When the ns and ew resolution are not the same, nearest neighbor resampling will be used to ensure both are the same.
-h
    skip header in csv
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

species : str | list[str], optional
    vector map(s) of species occurence
    Used as: input,
species_name : str, optional
    Alias-name(s) for species (default: map names).
evp_maps : str | list[str], required
    Environmental parameter map(s)
    Used as: input, raster
alias_names : str, optional
    Alias names for environmental parameter(s)
evp_cat : str | list[str], optional
    Categorial environmental parameter map(s)
    Used as: input, raster
alias_cat : str, optional
    Alias names for categorial parameter(s)
nbgp : str, optional
    Number or percentage of background points
    Used as: number
bgp : str, optional
    Vector layer with background / absence points
    Used as: input,
species_output : str, optional
    Species SWD file
    Used as: output, file, name
bgr_output : str, optional
    Background SWD file
    Used as: output, file, name
alias_output : str, optional
    CSV file with alias and map names
    Used as: output, file, name
export_rasters : str, optional
    Folder where to export the predictor raster layers to
    Used as: input, dir, name
format : str, optional
    Raster data format to write (case sensitive, see r.out.gdal)
    Allowed values: ascii, GeoTIFF
nodata : int, optional
    nodata value in output files
    Used as: number
    Default: -9999
seed : int, optional
    Seed for generating random points
    Default: 1
flags : str, optional
    Allowed values: t, e, h
    t
        Thin species and background points
        Select this flag if you want to limit the species and background points to maximum one point per raster cell. Note that this is already the case for the background points with the nbgp option.
    e
        Automatically adapt resolution
        When the ns and ew resolution are not the same, nearest neighbor resampling will be used to ensure both are the same.
    h
        skip header in csv
overwrite: bool, optional
    Allow output files to overwrite existing files
    Default: False
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

The v.maxent.swd takes one or more point vector layers with the location of species presence locations (parameter: species), and a set of raster layers representing relevant environmental variables (parameter: evp_maps). 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.

The user can also provide a point layer with background points (parameter: bgp). 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.

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 a header.

NOTES

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 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.

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):

g.region -a res=***

Alternatively, you can set the -e flag. 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.

This addon is a vector-based alternative to r.out.maxent_swd. 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. But note that you can use the -t 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.

EXAMPLES

The examples below use a dataset that you can download from here. It includes vector point layer with observation locations of the pale-throated sloth (Bradypus tridactylus) from GBIF, a number of bioclim raster layers from WorldClim, the IUCN RedList range map of the species, and a boundary layer of the South American countries from NaturalEarth.

The zip file contains a GRASS location. Unzip it and put it in a GRASS GIS database. Next, open GRASS GIS and go to the mapset southamerica. Download the zip file, and unzip it in a GRASS GIS database.

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

The output is a folder maxentinput 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 envlayers.

The created data layers can be used as input for Maxent. Alternatively, you can use it as input for the r.maxent.train addon, which provides a convenient wrapper for the Maxent software.

SEE ALSO

  • r.maxent.train addon to create/train a Maxent model. The addon provides a wrapper to the Maxent software.
  • r.out.maxent_swd, an alternative implementation of this addon, using species distribution data in raster format.
  • r.maxent.lambdas addon to compute raw or logistic prediction maps from MaxEnt lambdas files.

REFERENCES

  • MaxEnt 3.4.1 ( https://biodiversityinformatics.amnh.org/open_source/maxent)
  • 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.
  • Steven J. Phillips, Robert P. Anderson, Robert E. Schapire. Maximum entropy modeling of species geographic distributions. Ecological Modelling, 190:231-259, 2006.
  • 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.
  • GBIF.org (12 November 2023) GBIF Occurrence Download https://doi.org/10.15468/dl.br8b4a

AUTHOR

Paulo van Breugel, HAS green academy, Innovative Biomonitoring research group, Climate-robust Landscapes research group

SOURCE CODE

Available at: v.maxent.swd source code (history)
Latest change: Friday Feb 21 12:27:42 2025 in commit 8fce680