Hello everyone,
Am using ENMeval package in large study area(Africa) with high resolution bioclim data. Since my raster stack for Africa is too big and of 0.5m (very high) resolution, I cannot use the raster stack directly in the ENMevaluate function, otherwise I get a memory error. My idea is to extract the values of the occurences and prepare the relevant dataframes instead of using the raster stack directly. Am able to extract the values, prepare a dataframe and run my model in Maxent in R. (see my reproducable code below). Does someone have an idea of how to do this in ENMeval package (I mean using the prepared dataframes and not the raster stack) as this will avoid loading the heavy raster stacks. I would really appreciate any idea
# installing many packages at a time
#install.packages(c("rgbif","spdep", "nfc"))
# load the libraries
library(raster)
library(maptools)
library(dismo)
library(rgdal)
library(rJava)
library(corrplot)
file <- paste(system.file(package = "dismo"), "/ex/bradypus.csv", sep="")
bradypus <- read.table(file, header=T, sep=",")
dim(bradypus)
head(bradypus)
#we only need the 2 and 3 rows
bradypus <- bradypus[,2:3]
head(bradypus)
data("wrld_simpl")
plot(wrld_simpl, col="red", axes=T)
#environmental data or predictors
# Bioclim data provided by the package dismo
files <- list.files(path=paste(system.file(package="dismo"),"/ex", sep=""), pattern="grd", full.names=TRUE )
predictors <- stack(files)
plot(predictors)
plot(predictors, 1)
plot(wrld_simpl, add=T)
points(bradypus, col="blue", cex=0.5, pch=15)
# create background points
set.seed(8)
backgrd <- randomPoints(predictors, 500)
plot(wrld_simpl, col="red", axes=T)
points(bradypus, col="blue", pch=16, cex=0.3)
points(backgrd, col="yellow", pch=16, cex=0.5)
# Extracting values from the raster
envalspre <- extract(predictors, bradypus)
envalabse <- extract(predictors, backgrd)
head(envalspre)
head(envalabse)
#create predictor dataset
pb <- c(rep(1, nrow(envalspre)), rep(0, nrow(envalabse)))
sdmdata <- data.frame(cbind(pb, rbind(envalspre, envalabse)))
head(sdmdata)
names(sdmdata)
sdmdata$biome
sdmdata[,"biome"] <- as.factor(sdmdata[,"biome"])
head(sdmdata)
dim(sdmdata)
#create vector with equal length to the rows of sdmdata and containing contain 0 (background) and 1 (presence) values
my_p <- sdmdata[,1]
#correlation among predictors
pairs(sdmdata[,2:8], cex=0.1, fig=T)
corrplot(cor(sdmdata[,1:8]), type="lower", diag=F)
#Model fitting using model types
#Algorithms require different data structure, i.e. sdmdata, predictors, bradypus.
##Now plot with the prepared data frame
my_maxent <- maxent(sdmdata[,4:10], my_p)
class(my_maxent)
Regards,
Jeff
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/c2418f47-e017-4e1a-82f1-fc2d76d274c6n%40googlegroups.com.