BRECIplot | R Documentation |
Make a BRECI plot from two rasters output by an ENM fitting process. Typically, this is MaxEnt but any raster output from any ENM fitting method is acceptable provided that the rasters are on identical geometries and have values in gridcells scaled in the same way.
BRECIplot( ras1 = NULL, ras2 = NULL, outFilename = NULL, saveToFile = TRUE, plotTitle = "", plotWidth = 275, plotHeight = 200, brks = c(0, 0.2, 0.4, 0.6, 0.8, 1), binNames = c("V. low", "Low", "Med.", "High", "V. high"), binCols = c("dodgerblue", "darkolivegreen2", "gold1", "orange", "red"), scaleFactor = "numCells" )
ras1 |
rasterLayer. Full path to the baseline raster (earliest in time). |
ras2 |
rasterLayer. Full path to the future raster. |
outFilename |
Character. Full path to the output file. |
saveToFile |
Logical. Should the output plot be saved to file. DEFAULT = TRUE. |
plotTitle |
Character. Title to be give to the plot. |
plotWidth |
Integer. Width of the output plot in pixels. Default is 250 pixels. |
plotHeight |
Integer. height of the output plot in pixels. Default is 188 pixels. |
brks |
Numeric. An array of bin break points. Default gives 5 equally spaced bins between 0 and 1. |
binNames |
Character. An array of names assigned to the bins. |
binCols |
Character. An array of standard R colour names or hexadecimal colour values. |
scaleFactor |
Character. Selects scaling method for bin values. One of 'ras1Bins' or 'numCells' (default). See Details for an explanation. |
The two rasters to be compared using this function MUST have:
the same extent and resolution (grid cell size); and,
values in gridcells scaled in the same way. The rasters may be normalised values such that the sum of grid cell values across the extent = 1 (as in MaxEnt raw output) or adjusted so that values in a grid cell may range from 0 to 1 (as in MaxEnt logistic and cloglog output, and many other modelling methods).
scaleFactor determines the way in which values in bins are computed. Selecting 'ras1Bins' computes the value for a bin as a fraction of the number of pixels in the first raster. Values in a bin can therefore be greater than +/- 1, and are greatly exaggerated in size.
For the ith bin:
Bin_size(i) = [ras2_count(i) - ras1_count(i)]/ras1_count(i)
Selecting 'numCells' (the default value) computes the difference in the number of cells in that bin as a proportion of the total number of cells in the raster extent.
For the ith bin:
Bin_size(i) = [ras2_count(i) - ras1_count(i)]/Total_number_cells
This function is based on code developed in April 2017 but the first approach to this kind of index was developed in 2009-2010.
TRUE
## Not run: # Load first raster: ### ras1 <- raster("/path/to/ras1.tif") # Load second raster: ### ras2 <- raster("/path/to/ras2.tif") # Default plot BRECIplot(ras1, ras2, plotTitle = "Test ras1 and ras2", outFilename = "~/testPlot.png") # Stretch scaling to show relative changes more clearly BRECIplot(ras1, ras2, plotTitle = "ras1 & ras2 stretched", scaleFactor = "ras1Bins", saveToFile = FALSE) # Use a colour-blind friendly palette: BRECIplot(ras1, ras2, plotTitle = "ras5 & ras6: friendly palette", saveToFile = FALSE, binCols = cbPalette()) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.