Lab 8 - Maxent




Because we are using UW computers that do not, by default, have MaxEnt installed, we need to go and download the Java tool for use in this lab. Go to this link: . Fill out all of your info and proceed to download to your H: drives. Once you have completed the download process, open the maxent.jar file and you should see this GUI interface:



Raster data: Your environmental layers (i.e. your independent variables) have, to this point, been raster data stored as an ERDAS IMAGINE file (*.img). Unfortunately for us, the MaxEnt tool does not read this type of file and expects ASCII rasters to be available. All that an ASCII file is, is a text file with the first six lines providing the metadata and the remaining lines represent the values for each cell (rows and columns) within the raster. I have taken the opportunity to convert most of the rasters to ASCII. However, to provide one example of this process, let's convert our Study Area HUCs to an ASCII to act as a 'Mask' for our MaxEnt analyses.

  1. Add the SmallHUC.shp to ArcMap
  2. Add one of the ASCII rasters to use as the extent (i.e. elev.asc)
  3. Set the Environment so that the new raster matches the location and extent of the other rasters:
    1. In the Menu: Geoprocessing  → Environments...  → Processing Extent:  Set Extent = elev.asc, Snap Raster = elev.asc
  4. In the Toolbox: Conversion Tools → To Raster → Polygon to Raster: Set the Value Field = 'Gaz_ID', Output = SmallHuc.img, Cell Size= 30
    1. By choosing the Gaz_ID, we are setting values of the raster to equal to 1 or NoData, exactly what MaxEnt is expecting for a masking raster.
  5. Now we need to conver the .img to an ASCII: Conversion Tools  → From Raster  → Raster to ASCII: Set Input = SmallHuc.img, Output = mask.asc (please pay attention to your path and to the file extension. ArcGIS wants to name it .txt !)
  6. Next you need to make sure that the extents are equal between the elev.asc and mask.asc.
    1. In Windows Explorer: Right click elev.asc and Edit with Notepad++, right click mask.asc and Edit with Notepad++.
    2. Make sure that then Lower Left X and Y values are IDENTICAL!! Even one-one thousandth of a meter off will make MaxEnt unhappy.


Occurrence data: Recall that MaxEnt can predict a species potential distribution using only occurrence data. Given this fact, MaxEnt requires the occurrence data to be in a specific format. Follow these steps to get presence points into the correct format:

  1. Add the ParieeteCactus.shp to ArcMap
  2. Open its Attribute Table. You will notice a total of 4 Attributes. We need to delete every attriubte except for 'LATIN_NAME'
  3. Now we need to add in the XY coordinates for each point location. This shapefile MUST be in the same projection as the environmental data.
    1. In the Toolbox: Data Management Tools → Features → Add XY Coordinates. There should now be new POINT_X and POINT_Y columns
  4. MaxEnt requires the points to be stored as a *.csv (comma delimited file):
    1. Open the Attribute table of ParietteCactus → Table Options → Export: Choose a location; Save as Type = Text; File name = Pariette.csv
  5. The Pariette.csv needs to be edited to remove extra columns included by ArcGIS. To remove the columns from a csv:
    1. Open Excel → File → Open → Change Type to Text file → Select file → Delete the FID column → Save File (Answer Yes to the questions)

Our data are now ready for us to use MaxEnt



 With the data prepped and ready for analyses, we need to configure the MaxEnt model we wish to run. There are quite a few options and things to be aware of. The following steps will help guide you through some of the options available to you.

  1. Browse for the occurrence dataset, Pariette.csv
  2. Now browse for the folder containing the Environmental data (the ASCII rasters)
    1. The MaxEnt GUI should look something like this (see image below)

  3. Choose the Output directory. I recommend creating a new folder named 'Output' under your MaxEnt folder containing the Environmental data. In this folder, all of the MaxEnt output will be stored, including the predicted probabilities and the model evaluation statistics.

  4. If we are interested in assessing the effect/relationship of each independent variable on occupancy, we would want to check two options (Note- selecting these two options will increase the runtime of the model):
    1. Check 'Create response curves'
    2. Check 'Do jackknife to measure variable importance' 
  5. If we had data prepped for a landscape not included in our current Extent, we could have a directory of ASCII files that could have the MaxEnt model projected to. For this lab, we do not have that option specified.

  6. Click on the 'Settings' button. A new window will appear with three tabs.

  7.  On the Basic tab
    1. Of the Default settings, we will not make any changes to the Check Boxes except for checking Remove duplicate presence records

    2.  In our case, we have over 10,000 occurrence points. Therefore, we can feel relatively comfortable in specifying that we are willing to commit a percentage of our occurrence points to be the 'held-out' dataset used for assessing model accurracy. For this example, type in 25 for Random test percentage (25% of the occurrence points will now be used for 'testing' model fit).

    3. If we have decided that we didn't want to create a random output set of points, or we wanted to test the variability/robustness of our model, would could choose to perform a Cross-validation of the model. Just as we discussed previously, we would create a new MaxEnt model from a set of data and predict to the hold-out data, repeating this process k-fold times. WE WILL NOT PERFORM THIS IN CLASSS DUE TO TIME CONSTRAINTS AND LONG RUN-TIME. However, to set this property, you would simply change the Replicates to either 5 or 10 for the number of k-fold iterations.

  8.  On the Advanced tab
    1. I have typically left all of the defaults as they are. I have performed a couple of experiments in which I adjusted the Default prevalence value (i.e. by reducing the value from 0.5 to 0.1). I am still trying to fully assess the results of performing this parameter change.

    2. I refer you to the MaxEnt Tutorial file for better explanation of the Bias File .
  9. On the Experimental tab
    1. On this tab there are some interesting options, but as is typical I have rarely adjusted the default settings. Most of the settings are the minimum samples for each type of 'Feature'. 

    2. One nice option for you, if you do have a nicer, multi-core CPU with threading capabilities, you can tell MaxEnt how many parallel  threads that you want to run. Supposedly, if you enter a number greater than one the model run-time will be shorter. This number must not exceed the number of processor cores within your chip. (i.e. I have 12 cores so could potentially use 12 threads).
  10. Run the Model



After the model fitting is complete, we can view the output. To open the main summary output, in Windows Explorer navigate to your output folder and look for the Sclerocactus_brevispinus.html file. Double click to open in a Web-browser.

You will first see two separate graphs. To interpret the first graph, you are simply looking for the omission rates to match. The second plot is a ROC plot and the output provides you with an AUC value for the Training and Testing data. Recall that the steeper the curve, the better the model fit.