GRASS logo


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.


vector, export, Maxent


v.maxent.swd --help
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] [--help] [--verbose] [--quiet] [--ui]


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.
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.
skip header in csv
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


vector map(s) of species occurence
Alias-name(s) for species (default: map names).
evp_maps=string[,string,...] [required]
Environmental parameter map(s)
Alias names for environmental parameter(s)
Categorial environmental parameter map(s)
Alias names for categorial parameter(s)
Number or percentage of background points
Vector layer with background / absence points
Species SWD file
Background SWD file
CSV file with alias and map names
Folder where to export the predictor raster layers to
Raster data format to write (case sensitive, see r.out.gdal)
Options: ascii, GeoTIFF
nodata value in output files
Default: -9999
Seed for generating random points
Default: 1

Table of contents


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.


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.


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 \

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.




Paulo van Breugel, paulo at

HAS green academy University of Applied Sciences
Innovative Biomonitoring research group
Climate-robust Landscapes research group


Available at: v.maxent.swd source code (history)

Latest change: Saturday Feb 17 08:33:59 2024 in commit: 14ca14755f7a92b3cc31dd8eaa809e3a96659790

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual