project_maxent: Project a fitted Maxent model

Description Usage Arguments Details Value Warning Author(s) References See Also Examples

Description

Project a fitted Maxent model by predicting to new environmental data.

Usage

1
project_maxent(lambdas, newdata, mask, quiet = FALSE)

Arguments

lambdas

Either a MaxEnt fitted model object (fitted with the maxent function in the dismo package), or a file path to a Maxent .lambdas file.

newdata

A RasterStack, RasterBrick, list, data.frame, data.table, or matrix that has layers/elements/columns whose names correspond to the names of predictors used to fit the model. These layers/elements/columns must all have the same length.

mask

(Optional; requires that newdata is a Raster* object.) A Raster object with NA values in cells for which the model should not be projected. These cells will be assigned NA in the returned output.

quiet

Logical. Should projection progress be reported?

Details

project_maxent uses feature weights described in a .lambas file or MaxEnt object to predict a Maxent model to environmental data. This function performs the projection entirely in R, without the need for the Maxent Java software. For tested datasets, it performs the projection in roughly one third of the time taken for the same projection by maxent.jar.

Value

If newdata is a RasterStack or RasterBrick, a list with two elements:

If newdata is not a RasterStack or RasterBrick, the raster layers will be replaced with data.tables in the returned list.

Warning

This function is still in development, and no guarantee is made for the accuracy of its projections.

Author(s)

John B. Baumgartner, johnbaums@gmail.com

References

See Also

read_mxe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Below we use the dismo::maxent example to fit a Maxent model:
if (require(dismo) && require(rJava) && 
    file.exists(file.path(system.file(package='dismo'), 'java/maxent.jar'))) {
  fnames <- list.files(path=paste(system.file(package="dismo"), '/ex', sep=''),
                       pattern='grd', full.names=TRUE )
  predictors <- stack(fnames)
  occurence <- paste(system.file(package="dismo"), '/ex/bradypus.csv', sep='')
  occ <- read.table(occurence, header=TRUE, sep=',')[,-1]
  me <- maxent(predictors, occ, factors='biome')

  # ... and then predict it to the full environmental grids:
  pred <- project_maxent(me, predictors)
  # This is equivalent to using the predict method for MaxEnt objects:
  pred2 <- predict(me, predictors)
  all.equal(values(pred$prediction_logistic), values(pred2))
}

johnbaums/things documentation built on May 19, 2019, 3:03 p.m.