简体   繁体   中英

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;

  • What arguments to supply to predict given a model of this type
  • What predict() is capable of providing from a model such as this

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])

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.

If you provide dismo::maxent a dataframe, the function will recognize the first column as longitude and second column as latitude. If the data not follow this format, the function will not work.

In this format sightings data does not need to include the GPS locations, so you can remove the x & y columns from sightings.data. Then you can run the model, and then you can predict to a raster stack with raster names that are identical to the names in the sightings.data column names.

Predict was looking for the GPS locations in your raster stack, which I'm guessing were not there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM