rpredictmaxentdismo

How to use Dismo's predict() with a maxent model based on a dataframe


I am trying to figure out how dismo's predict function operates in terms of a model built with 'x' as a dataframe, rather than raster layers. I have successfully run models using raster layers and made prediction maps based on this.

My model is built as follows;

library(dismo)
model <- maxent(x = sightings.data, p = presence.vector)

with sightings.data being a dataframe containing the GPS locations of sightings, followed by the conditions at these times and locations. presence.vector is a vector indicating if a row is a presence or background point.

I am looking to find out;

I have successfully run models using raster layers and made prediction maps based on this.

The help file for predict() is not particularly detailed and the 'Species distribution modelling with R' does not successfully cover this topic (the examples just list 'cannot run this example because maxent is not available' outputs).

I have tried modelling with a dataframe containing only variables I have raster layers for, and tried predicting as I would for a model built with rasters, but I get the following error;

 Error in .local(object, ...) : missing layers (or wrong names)

I have ensured the dataframe column names and the raster layers have the same names, excluding the mandatory latitude and longitude columns;

 names(raster.stack) <- colnames(sightings.data[3:5])

Solution

  • The method I have found from the code avaialble from the following paper Oppel at al 2012 demonstrates that dismo's predict can produce relative values when provided with a dataframe of input variables.

    > predictions <- predict(model, variables)
    > str(predictions)
      num [1:100] 0.635 ...
    

    I'm still looking for an easy method to create a predicted distribution raster map from such predicted values.