iiasa / ibis.iSDM

Modelling framework for creating Integrated SDMS
https://iiasa.github.io/ibis.iSDM/
Creative Commons Attribution 4.0 International
20 stars 2 forks source link

How to obtain habitat suitability index (0 - 1) working with presence-only and oportunistic data (GBIF) #48

Closed ManuelSpinola closed 1 year ago

ManuelSpinola commented 1 year ago

I really like the package.

I am working with presence-only and oportunistic data, for example, from GBIF.

How can I obtain the output and map from an specific engine in habitat suitability index (between 0 and 1).

Martin-Jung commented 1 year ago

Heya, two possibilities to obtain a 'suitability index':

1) Simply add pseudo-absences as is common practice. This can be done using add_pseudoabsence() using a method of your choice (random, buffer, etc...). See the help file in pseudoabs_settings. Example code

# Define pseudo-absence settings
abs <- pseudoabs_settings(background = background, nrpoints = 10000, method = "mcp",inside = FALSE)

# Convert presence-only points in sf format to presence-absence
# Field_occurrence points to a 
poa <- my_gbifpoints |> add_pseudoabsence(field_occurrence = "Observed",
                                          template = background, 
                                          settings = abs # Settings from above
                                          )

# Train a model
fit <- distribution(background) |> 
  # Presence-absence data
  add_biodiversity_poipa(poa) |> 
  add_predictors(predictors) |> 
  engine_glmnet() |> 
  train()

plot(fit) 
write_output(fit, "myprediction.tif")

2) Fit a model using a Poisson Process model. Here the output unit is number of observations per unit area, thus needs to be transformed / normalized if you need a layer in units 0-1. Example code

# Train a model
fit <- distribution(background) |> 
  # Presence-absence data
  add_biodiversity_poipo(my_gbifpoints) |> 
  add_predictors(predictors) |> 
  engine_glmnet() |> 
  train()

plot(fit) # This might have different units

# Get the prediction
pred <- fit$get_data() |> 
  predictor_transform(option = "norm")

I will add soon an option to allow predictor_transform() also on the direct output from train to ease this up a bit as well as different options for normalization. Currently this is done via (x - min) / (max - min)

Cheers, Martin

Martin-Jung commented 1 year ago

Functionality added and now merged in latest version 0.0.4. See Frequently asked questions (Other at the bottom for an example).

ManuelSpinola commented 1 year ago

Thank you very much Martin.

El lun, 12 jun 2023 a las 14:01, Martin Jung @.***>) escribió:

Functionality added and now merged in latest version 0.0.4. See Frequently asked questions (Other at the bottom for an example https://iiasa.github.io/ibis.iSDM/articles/06_frequently-asked-questions.html ).

— Reply to this email directly, view it on GitHub https://github.com/iiasa/ibis.iSDM/issues/48#issuecomment-1587999045, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFI3FB3SU3DXQ7WNZSIC5CLXK5YSXANCNFSM6AAAAAAY3GQZUA . You are receiving this because you authored the thread.Message ID: @.***>

-- Manuel Spínola, Ph.D. Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA @. @.> @.*** Teléfono: (506) 8706 - 4662 Sitio web institucional: ICOMVIS http://www.icomvis.una.ac.cr/index.php/manuel Sitio web personal: Sitio personal https://mspinola-sitioweb.netlify.app Blog sobre Ciencia de Datos: Blog de Ciencia de Datos https://mspinola-ciencia-de-datos.netlify.app