This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

print("Hello World!")

For maxent installation please go to: https://biodiversityinformatics.amnh.org/open_source/maxent/

Please run the following code to check the avaiable packages and install if necessary

RequiredPackages <- c("rgeos", "raster","doParallel", "foreach", "rJava", "dismo", "maptools", "DiagrammeR", "sp", "sf", "rmarkdown", "CanHeMonR.MaxEnt", "dplyr", "ggplot2") 
for (i in RequiredPackages) { #Installs packages if not yet installed
    if (!require(i, character.only = TRUE)) install.packages(i)
}
dismo::maxent()

Algorithm flowchart

DiagrammeR::DiagrammeR("
graph TB
    A>Point shapefile with precences] --> D[Sample presences and backgroud points]
    B>Raster files and textures to run] --> D
    D --> E>Serialized object with the presence and background points]
    E --> F[Calibration and creation of MaxEnt model]
    F --> G>Serialized object with the model]
    G --> H[Run model over the tiles]
    B --> H
    H --> I>Tif files with the MaxEnt predictions]
    I --> J[Post-process of gemoetry operations]
    J --> K>Point shapefiles]
    K --> L[Visual inspection od the output model]
    L --> D
")

Sampling presence and pseudo-absent data for maxent

Function that creates a sample dataframe for the selected classes with the presences and background points for the selected rasters. This sample will be used as training data for image classification through MaxEnt

Inputs

More information and examples of the function in the code

Output
Function

You can set the parameters and run it in the R console with:

render("sample_points.r", params = list(r_train_dir= "" ,
                                        text_train_dir= "",
                                        tile= "",
                                        text= "",
                                        prob_tifs= "",
                                        vuln_classes= "",
                                        training_pol_filename= "", 
                                        field_name= "",
                                        nimputs_tile="",
                                        data_outp_dir="",
                                        abs_samp= "",
                                        parallel= "",
                                        nWorkers= "",
                                        data_outp_name= "",
                                        randompt= "", 
                                        EOS= ""))

Calibrate and creation of the MaxEnt model

Calibration and creation of the model for each class selected in the previous step, using a raster brick as predictors. If desired, it can output also the stadisctics of the model to measure the preformace.

Inputs

More information and examples of the function in the code

Output
Function

You can set the parameters and run it in the R console with:

render("calibrate_model.r", params = list(vuln_classes = "", 
                                          training_path = "", 
                                          model_outp_dir = "", 
                                          name = "",
                                          stadistics = "", 
                                          myargs = "", 
                                          model_type = "",
                                          stadisticspath = ""))

Run model

Run a saved MaxEnt model on the image data you want to predict.

Inputs

More information and examples of the function in the code

Output
Function

You can set the parameters and run it in the R console with:

render("run_model.r", params = list(predictor_dir = "",
                                         text_train_dir = "",
                                         MaxEntmodel_dir = "",
                                         fname_MaxEntmodel_r = "",
                                         output_dir = "",
                                         rastername = "",
                                         model_type = "",
                                         EOS = ""))

Creation of the thresholds for rasters

Creation of several serialized objects with different thresholds in order to select the one that maximized the retrival of Pine trees with the less false positive possible.

Inputs

More information and examples of the function in the code

Output
Function

You can set the parameters and run it in the R console with:

render("sick_tree_errors.r", params = list(r_pred_dir  = "", 
                                           tile  = "", 
                                           prefix = "", 
                                           vuln_classes = "", 
                                           training_pnt_filename = "", 
                                           radius = "", 
                                           field_name = "", 
                                           abs_samp  = "",
                                           minthresh = "", 
                                           maxthresh = "", 
                                           stepthresh = "",
                                           parallel = "", 
                                           nWorkers = "", 
                                           data_outp_dir = ""))

Selection of the best threshold for rasters and poligonization

Selection of the best cut-off probability thresholds that selects the one that maximized the retrival of Pine trees with the less false positive possible. Selection of the smallest number of pixels detected inside a true tree-disk. Poligonization of the raster files with the selected parameters.

Inputs

More information and examples of the function in the code

Output
Function

You can set the parameters and run it in the R console with:

render("MaxCutoff", params = list(input_dir  = "", 
                                  plots  = "", 
                                  stadisticspath  = "", 
                                  prefix  = "", 
                                  max_error  = "", 
                                  cla  = "", 
                                  r_pred_dir  = "", 
                                  tile  = "", 
                                  max_area  = "", 
                                  res  = "", 
                                  outp_dir  = ""))


MartinezLaura/CanHeMonR.MaxEnt documentation built on May 17, 2019, 6:21 p.m.