| Title: | Ecological Tolerance Indices |
|---|---|
| Description: | Computes the Road Tolerance Index (RTI) and the Human Footprint Tolerance Index (HFTI) for species occurrence data. It automates data cleaning and integrates spatial data (roads and human footprint) to produce reproducible tolerance metrics for biodiversity and conservation research. The HFTI calculation is based on the global human footprint dataset by Mu et al. (2022) <doi:10.1038/s41597-022-01284-8>. This package is part of a PhD thesis focused on amphibian ecology in Brazil. |
| Authors: | Diego F. Miranda [aut, cre], Lucas R. Forti [aut] |
| Maintainer: | Diego F. Miranda <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-05-21 10:19:08 UTC |
| Source: | https://github.com/cran/ecoTolerance |
This function calculates the HFTI for each species occurrence based on the average human footprint within a 1 km buffer around each occurrence.
calculate_HFTI(occurrences, footprint, divisor = 50, buffer_m = 1000)calculate_HFTI(occurrences, footprint, divisor = 50, buffer_m = 1000)
occurrences |
An sf object containing processed occurrences. |
footprint |
A RasterLayer containing human footprint values. |
divisor |
A numeric value to divide the footprint by (default = 50). |
buffer_m |
Numeric. Buffer size in meters for footprint extraction (default = 1000). |
A list with:
The sf object of occurrences with a new column HFTI_value.
A data frame with the median HFTI per species.
# Note: simple example using the internal "toy" data footprint <- load_human_footprint() # We need dummy occurrence data for the example to run occ_data <- data.frame(species = "SpA", longitude = -38.4, latitude = -12.6) processed <- process_occurrences(occ_data) hfti_result <- calculate_HFTI(processed, footprint, divisor = 50, buffer_m = 1000)# Note: simple example using the internal "toy" data footprint <- load_human_footprint() # We need dummy occurrence data for the example to run occ_data <- data.frame(species = "SpA", longitude = -38.4, latitude = -12.6) processed <- process_occurrences(occ_data) hfti_result <- calculate_HFTI(processed, footprint, divisor = 50, buffer_m = 1000)
Esta função calcula o RTI para cada ocorrência de espécie com base na distância mínima até a estrada mais próxima. A fórmula usada é:
calculate_RTI(occurrences, roads, ref_dist = 3.5)calculate_RTI(occurrences, roads, ref_dist = 3.5)
occurrences |
Um objeto |
roads |
Um objeto |
ref_dist |
Distância de referência em quilômetros (padrão = 3.5). |
Se dist = 0, então RTI = 1. Conforme dist aumenta, RTI
aproxima-se de 0.
Uma lista com:
O objeto sf de ocorrências, porém com uma nova
coluna RTI_value com o índice calculado.
Um data frame com a mediana de RTI por espécie.
# Carregar rodovias de exemplo (Toy data) roads <- load_roads() # Criar dados de ocorrencia ficticios na area do Toy Data occ_data <- data.frame( species = "SpA", longitude = -38.4, latitude = -12.6 ) # Processar ocorrencias processed <- process_occurrences(occ_data) # Calcular RTI rti_res <- calculate_RTI(processed, roads, ref_dist = 3.5)# Carregar rodovias de exemplo (Toy data) roads <- load_roads() # Criar dados de ocorrencia ficticios na area do Toy Data occ_data <- data.frame( species = "SpA", longitude = -38.4, latitude = -12.6 ) # Processar ocorrencias processed <- process_occurrences(occ_data) # Calcular RTI rti_res <- calculate_RTI(processed, roads, ref_dist = 3.5)
This main function processes occurrence data (removing duplicates, filtering close points), then calculates the Highway Tolerance Index (RTI) and the Human Footprint Tolerance Index (HFTI).
compute_indices( data, remove_duplicates = TRUE, buffer_km = 1, ref_dist = 3.5, divisor = 50, data_type = "toy" )compute_indices( data, remove_duplicates = TRUE, buffer_km = 1, ref_dist = 3.5, divisor = 50, data_type = "toy" )
data |
A data frame with columns "species", "longitude", and "latitude". |
remove_duplicates |
Logical. If TRUE, remove exact duplicates of species + coordinates. |
buffer_km |
Numeric. Buffer size in kilometers for removing nearby points. |
ref_dist |
Numeric. Reference distance in kilometers for RTI. |
divisor |
Numeric. Divisor for the human footprint values in HFTI. |
data_type |
Character. Options are "toy" (default) or "full". |
A list containing:
A data frame with median RTI values per species.
A data frame with median HFTI values per species.
A data frame combining both RTI and HFTI by species.
The sf object of occurrences with RTI and HFTI values.
# Example usage with internal toy data # Using coordinates that fall within the provided toy dataset (Bahia, Brazil) sample_data <- data.frame( species = c("SpA", "SpA", "SpB", "SpB"), longitude = c(-38.40, -38.41, -38.42, -38.43), latitude = c(-12.60, -12.61, -12.62, -12.63) ) result <- compute_indices( data = sample_data, remove_duplicates = TRUE, buffer_km = 1, ref_dist = 3.5, divisor = 50 ) print(result$RTI) print(result$HFTI) print(result$indices)# Example usage with internal toy data # Using coordinates that fall within the provided toy dataset (Bahia, Brazil) sample_data <- data.frame( species = c("SpA", "SpA", "SpB", "SpB"), longitude = c(-38.40, -38.41, -38.42, -38.43), latitude = c(-12.60, -12.61, -12.62, -12.63) ) result <- compute_indices( data = sample_data, remove_duplicates = TRUE, buffer_km = 1, ref_dist = 3.5, divisor = 50 ) print(result$RTI) print(result$HFTI) print(result$indices)
Esta funcao recebe o resultado de compute_indices(), um shapefile
de area de estudo e o diretorio de saida. Para cada especie presente em
result$processed_data, ela gera:
Mapa de RTI (points coloridos por RTI_value)
Mapa de HFTI (points coloridos por HFTI_value)
Grafico de densidade de RTI (com linha vertical na mediana)
Grafico de densidade de HFTI (com linha vertical na mediana) Alem disso, salva um arquivo CSV com RTI e HFTI medios por especie.
generate_all_reports( result, area_shapefile, out_dir, map_crs = 4326, point_size = 1.5, density_fill = "steelblue", density_alpha = 0.35 )generate_all_reports( result, area_shapefile, out_dir, map_crs = 4326, point_size = 1.5, density_fill = "steelblue", density_alpha = 0.35 )
result |
Lista retornada por
|
area_shapefile |
Caminho (string) para o shapefile da area de
estudo (por exemplo, limite do Brasil). Deve ser um arquivo |
out_dir |
Caminho (string) para o diretorio onde as imagens e o CSV serao salvos. Caso nao exista, sera criado automaticamente. |
map_crs |
CRS desejado para os mapas (padrao = 4326, WGS84). |
point_size |
Tamanho dos pontos nos mapas (padrao = 1.5). |
density_fill |
Cor de preenchimento dos graficos de densidade (padrao = "steelblue"). |
density_alpha |
Transparencia do preenchimento dos graficos de densidade (padrao = 0.35). |
Invisivel. A funcao retorna NULL apos salvar todos os arquivos
em out_dir.
This function loads the human footprint data. By default, it loads a small "toy"
raster included in the package. To use the full Brazil raster, set type = "full".
load_human_footprint(type = "toy")load_human_footprint(type = "toy")
type |
Character. Options are "toy" (default) or "full". |
A RasterLayer object containing human footprint data.
This function loads the roads data. By default, it loads a small "toy" dataset
included in the package for testing and examples. To use the full dataset
(all Brazilian roads), set type = "full". The full dataset will be
downloaded from Zenodo upon the first request and cached locally.
load_roads(type = "toy")load_roads(type = "toy")
type |
Character. Options are "toy" (default) or "full". |
An sf object containing roads data.
This function processes species occurrence data by optionally removing duplicates and filtering out points that are closer than a specified distance (buffer).
process_occurrences(data, remove_duplicates = TRUE, buffer_km = 1)process_occurrences(data, remove_duplicates = TRUE, buffer_km = 1)
data |
A data frame containing at least the columns "species", "longitude", and "latitude". |
remove_duplicates |
Logical. If TRUE, remove exact duplicates of species + coordinates. |
buffer_km |
The buffer size in kilometers used to filter out close points. |
An sf object with the processed occurrences.
# Example data occ_data <- data.frame( species = c("SpA", "SpA", "SpB", "SpB"), longitude = c(-50, -50.0005, -51, -51.001), latitude = c(-10, -10.0005, -11, -11.001) ) processed <- process_occurrences( data = occ_data, remove_duplicates = TRUE, buffer_km = 1 ) processed# Example data occ_data <- data.frame( species = c("SpA", "SpA", "SpB", "SpB"), longitude = c(-50, -50.0005, -51, -51.001), latitude = c(-10, -10.0005, -11, -11.001) ) processed <- process_occurrences( data = occ_data, remove_duplicates = TRUE, buffer_km = 1 ) processed