Post-Processing Models

Hannah Owens
13 April, 2018

I have niche models. Now what?

I have niche models. Now what?

  • Thresholding
  • Niche characterization
    • Extent of predicted area
    • Extracting descriptive statistics

Post-processing your models

library(raster);

Now what? Thresholding

Thresholding to 95% suitabilty score

  • Getting suitability scores
codPoints <- read.csv("cleanCodPointsSPOCC.csv"); #get your ocurrences
gadusMorhuaModel <- raster("Gadus_morhuaModel.asc"); #get your model
suitabilityScores <- extract(gadusMorhuaModel, codPoints[,2:3]); #Extract suitability
suitabilityScores <- suitabilityScores[complete.cases(suitabilityScores)] #No NAs

Now what? Thresholding

Thresholding to 95% suitabilty score

  • Reclassify raster
    • For each reclassification category, give a minimum value, a maximum value, and the new value
threshold <- sort(suitabilityScores, decreasing = T)[round(length(suitabilityScores)*.95,0)] #Takes 5th percentile suitability score
m <- c(0, threshold, 0,  threshold, 1, 1); #makes reclassification list
rclmat <- matrix(m, ncol=3, byrow=TRUE); #turns list into a matrix
codDist <- reclassify(gadusMorhuaModel, rcl = rclmat);
#codDist can be saved like any other raster file (refer to Lab 2);

Now what? Thresholding

Thresholding to 95% suitabilty score

plot(gadusMorhuaModel);
plot(codDist);

plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5

Now what? Calculating area predicted present

Thresholding to 95% suitabilty score

cellAreas <- area(codDist)*codDist
plot(cellAreas);
cellAreaMeasures <- rasterToPoints(cellAreas);
paste("The area of the species' distribution is ", sum(cellAreaMeasures[,3]), " km2.", sep="");
[1] "The area of the species' distribution is 3860150.20879097 km2."

plot of chunk unnamed-chunk-6

Now what? Niche characterization

Inferring characteristics of suitable niche space

  • Inferring limiting factors

Now what? Niche characterization

Get environmental data

setwd("Present/");
envtList <- list.files(pattern = ".asc")
envtStack <- stack(envtList);
setwd("~/Dropbox/ENMSeminar/Labs:Homeworks/Lab9/Data/")

Now what? Niche characterization

Basic niche characterization

  • Extracting descriptive statistics
gadusMorhuaSuit <- envtStack * codDist;
names(gadusMorhuaSuit) <- names(envtStack);
gadusMorhuaPts <- cbind(codPoints, extract(envtStack, codPoints[,2:3]));
gadusMorhuaPts <- gadusMorhuaPts[complete.cases(gadusMorhuaPts),]

Now what? Niche characterization

cellStats(envtStack[[-1]], stat = 'max'); #Maximum across training region
[1] 99.99342 99.17279 42.67882 29.10242
cellStats(gadusMorhuaSuit[[-1]], stat = 'max'); #Maximum in ENM-inferred suitable space
[1] 99.66620 74.39768 36.26730 23.74734
noquote(summary(gadusMorhuaPts[,5:9], digits = 2)[6,-1]); #Maximum at occurrences
             imax              imin              savg              tavg 
Max.   :71.8259     Max.   :1.141      Max.   :36.2      Max.   :22.0