Skip to end of metadata
Go to start of metadata

This page provides an outline of the workflow to create species distribution/range models for BIEN.
Text in purple describes a read operation, while text in red describes a write operation.

R Script: ComputerRageAreasNEW.r 

Requires:

Workflow:

  1. Set working directory base path
  2. Set output directories from working directory
  3. Set background raster layer for clipping raster output to continental margin
  4. Record start time
  5. Read a CSV file, i.e. “Abies balsamea UTM.csv” into a data frame
  6. Define the data frame as spatial points and assign our UTM projection
  7. Create a convex hull vector polygon from UTM points
  8. Get the spatial extent of the convex hull – sets the spatial extent of the bounding box
  9. Compute latitudinal and longitudinal range (in meters)
  10. Create a vector polyon of the bounding box area
  11. Create a latitudinal band (min and max latitudinal extent plus min and max continental longitude extent)
  12. Create raster layers of the points, convex hull, bounding box and latitude extent polygons
  13. Clip the rasters using the continental background raster to remove ocean, etc.
  14. Get cell counts for points convex hull, bounding box and latitude extent raster layers (clipped versions)
  15. Calculate area from cell counts
  16. Write the resulting raster layers to disk:
    1. points
    2. convex hull
    3. bounding box
    4. latitude extent
  17. Record the results in a matrix to hold the statistics
  18. Write the matrix to a CSV file as part 1 - optional
  19. Initiate a maxent run for all 19 Bioclim environmental layers
    1. Prepare a stack of environmental layers for maxent
    2. Send species name, points, background raster, environmental layers,  model type and output directory variables to Maxent function (CreateSDMFunctionNEW.r) to run maxent and return a data frame of results.
  20. Initiate a maxent run for 19 Spatial filter layers
    1. Prepare a stack of environmental layers for maxent
    2. Send species name, points, background raster, environmental layers,  model type and output directory variables to Maxent function (CreateSDMFunctionNEW.r) to run maxent and return a data frame of results.
  21. Initiate a maxent run for all 19 Bioclim environmental layers + 19 spatial filter layers
    1. Prepare a stack of environmental layers for maxent
    2. Send species name, points, background raster, environmental layers,  model type and output directory variables to Maxent function (CreateSDMFunctionNEW.r) to run maxent and return a data frame of results.
  22. Record the end time
  23. Combine matrices from part 1 and individual maxent runs into a large matrix
  24. Write full matrix of all results to a CSV file
  25. Finished

-- New Function --

R Script: CreateSDMFunctionNEW.r

R function that receives input from ComputerRageAreasNEW.r, runs maxent and records resulting raster layers and statistics. Returns a matrix of results.

Requires:

  • R library rJava

Workflow:

  1. Perform Kfold partitioning to withhold 20% of the points for testing
  2. Split points into training points and testing points
  3. Run maxent to fit the training points to a model
  4. Use the resulting model to predict to entire dataset
  5. Write the resulting maxent raster layer to a file
  6. Evaluate the resulting maxent model
    1. Create random point sample of background variables and use with testing points to evaluate model
    2. Obtain evaluation statistics
      1. Number of presences
      2. Number of absences
      3. AUC
      4. Correlation
      5. Kappa score at maximum kappa
    3. Obtain true/false positive/negative totals from the confusion table
      1. True positive
      2. False positive
      3. True negative
      4. False negative
      5. Calculate sensitivity
      6. Calculate specificity
      7. Calculate overall accuracy (correct/total)
  7. Record all returned model thresholds
    1. Get the threshold at 
      1. a) maximum training sensitivity and specificity
      2. b) equal training sensitivity and specificity, and
      3. c) maximum kappa
  8. Resample the maxent raster layer to a new binary raster layer of cells that equal or exceed the maximum training sensitivity and specificity threshold value
  9. Write the binary thresholded raster layer to disk
  10. Get cell count and area of binary thresholded raster layer
  11. Record all maxent result statistics to a matrix for returning to the main function
  12. Write maxent statistics to CSV file (Part 2) - optional
  13. Write all returned thresholds to CSV file (for later use in a separate analysis not included here)
  14. Return matrix to main function

-- End of Document --

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.