View source: R/advanced_cleaning.R
| advanced_cleaning | R Documentation |
Advanced processes of data cleaning involving duplicate removal and movement of records.
advanced_cleaning(data, x, y, raster_layer, cell_duplicates = TRUE,
move_points_inside = FALSE, move_limit_distance = NULL,
verbose = TRUE)
remove_cell_duplicates(data, x, y,
raster_layer)
move_2closest_cell(data, x, y, raster_layer,
move_limit_distance, verbose = TRUE)
data |
data.frame with occurrence records. Rows with NA values will be omitted. |
x |
(character) name of the column in |
y |
(character) name of the column in |
raster_layer |
a raster layer (object of class
|
cell_duplicates |
(logical) whether to remove duplicate coordinates considering raster cells. Default = TRUE. |
move_points_inside |
(logical) whether to move records outside of raster cells with valid values to the closest cell with values. Default = FALSE. |
move_limit_distance |
maximum distance to move records outside cells
with valid values. Default = NULL. Must be defined if
|
verbose |
(logical) whether to print messages of progress. Default = TRUE. |
Data used in this functions should have gone through initial processes of cleaning and filtering.
A data.frame with occurrence records resulting from advanced cleaning procedures. Other columns will be added to describe changes made in the original data.
initial_cleaning()
# Import occurrences
data(occ_data_noclean, package = "kuenm2")
# Import raster layers
var <- terra::rast(system.file("extdata", "Current_variables.tif",
package = "kuenm2"))
# Keep only one layer
var <- var$bio_1
# all basic cleaning steps
clean_init <- initial_cleaning(data = occ_data_noclean, species = "species",
x = "x", y = "y", remove_na = TRUE,
remove_empty = TRUE, remove_duplicates = TRUE,
by_decimal_precision = TRUE,
decimal_precision = 2)
# Advanced cleaning steps
# exclude duplicates based on raster cell (pixel)
celldup <- remove_cell_duplicates(data = clean_init, x = "x", y = "y",
raster_layer = var)
# move records to valid pixels
moved <- move_2closest_cell(data = celldup, x = "x", y = "y",
raster_layer = var, move_limit_distance = 10)
# the steps at a time
clean_data <- advanced_cleaning(data = clean_init, x = "x", y = "y",
raster_layer = var, cell_duplicates = TRUE,
move_points_inside = TRUE,
move_limit_distance = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.