As part of my PhD research at the University of Arizona where I study biogeography, biodiversity and macroecology, I have been part of a group looking at large-scale biodiversity questions for New World plants. In this role, I have been responsible for generating many species distribution models using Stephen Phillip’s Maxent software (and R with the Dismo package). I also use ArcGIS quite often to prepare environmental data for Maxent modeling, and wanted a way to perform and integrate Maxent modeling into my ArcGIS workflows.
When working with data and analysis, my rule is that if I have to do something complicated more than twice, it’s generally worth it to develop an automated workflow. So for my species distribution modeling needs, I wanted a Maxent script tool that I could use as a standalone geoprocessing tool or embed within a ModelBuilder model for use more complicated workflows. For example, one of my most common workflow is iterating through a list of species and running a species distribution model for each one.
To accomplish this, I wrote an ArcGIS script tool in Python that collects a variety of common Maxent parameters in a typical ArcGIS geoprocessing user interface and populates a command string to execute Stephen Phillip’s maxent.jar Java application via a Python call to execute a system command. The resulting script tool uses the arcpy model, so it works like any other ArcGIS geoprocessing script tool. It can operate as a standalone tool to generate a species distribution model for a single species, or can be placed into a ModelBuilder workflow and linked to input parameters as shown in the example below.
In this example, the script tool is parameterized with a species occurrence dataset obtained from the iterator object in which each dataset is named genus_species.csv. The tool then generates a species distribution model for each species and saves the model to a separate directory within a designated output directory, naming each directory by the genus and species name specified in the name of the input occurrence dataset.
A partial example of the Python script that obtains the parameters from the input datasets is shown below.
These parameters are then appended to a string object that is a system command call:
myCommand = "java -mx512m -jar \"" + maxent + "\" -e \"" + climatedataFolder + "\"" myCommand += " -s \"" + csvFile + "\" -o \"" + newOutputFolder + "\"" myCommand += " outputformat=" + optOutputFormat.lower() + " outputfiletype=" + optOutputFileType.lower()
result = os.system(myCommand)
When the maxent.jar Java application launches, you’ll see the typical Maxent GUI that you would see if you launched maxent.jar directly and ran a model manually. Except in this case the maxent.jar application launches and starts the model automatically, as shown below.:
Of course there are some additional script lines that are not shown in the examples above add other maxent parameters to the command string and evaluate the result of the os.system call to determine whether the command executed correctly or not.
However, I have placed a copy of a simple ArcGIS Toolbox and the associated Python script in a zipfile that you can download for your own modeling uses at the link below. There are different versions for each version of ArcGIS you may be using. While newer versions of ArcGIS can read older toolboxes, older versions of ArcGIS cannot read newer toolboxes. So be sure to download the file below that is most appropriate for your ArcGIS version.
- ArcGIS_Maxent_Toolbox_10.1.zip [for ArcGIS 10.1 or 10.2.x]
- ArcGIS_Maxent_Toolbox_10.0.zip [for ArcGIS 10.0]
- ArcGIS_Maxent_Toolbox_9.3.zip [for ArcGIS 9.3]
If you like the tool, please let me know if you have any questions or comments/ideas. This is a fairly simple first implementation that I built to get through a lot of modeling quickly. However, I have a few ideas for additions to the tool that would enable it to handle species occurrence point data directly (instead of using saved CSVs) and perhaps leverage Maxent cache (.mxe) files instead of using the environmental data ASC files for each model iteration. At the moment, I’m too busy to add these, but it may be something I add in the future to round out the tool better.