maxnetmap

The goal of maxnetmap is to create a raster from a spatial distribution model fitted with glmnet via maxnet package

Installation

You can install maxnetmap from github with:

# install.packages("devtools")
devtools::install_github("alrobles/maxnetmap")

Example

This is a basic example which shows you how to solve a common problem:

## basic example code
library(spocc)
library(raster)

# get enviromental variables
currentEnv <- raster::getData("worldclim", var="bio", res=2.5)
#set an extent
model_extent <- raster::extent(-130,-60,25,50) 

#crop the enviromental layers
modelEnv <- raster::crop(currentEnv, model_extent)
#get the points of rice
pts <- spocc::occ("Oryza sativa", geometry = as.vector(model_extent) ) %>% 
    spocc::occ2df() %>% 
    dframe() %>% 
    coord_impossible() %>%
    coord_incomplete() %>%
    coord_unlikely()

#plot a layer with the points
plot(modelEnv[[1]])
points(pts[ ,2:3],col="red", pch=20, cex=0.3)


#feature classes (Could be linear, product,
# quadratic, hinge or combination of all of them)
fclasses = "lpq"

# get a maxent model with the raster
me <- maxentRaster(modelEnv, pts[ ,2:3], fclasses)

#raster
plot(me[[1]])

#model
plot(me[[2]])
me[[2]]$nulldev


alrobles/maxnetmap documentation built on May 29, 2019, 12:36 p.m.