Learn R Programming

glossa (version 1.0.0)

clean_coordinates: Clean Coordinates of Presence/Absence Data

Description

This function cleans coordinates of presence/absence data by removing NA coordinates, rounding coordinates if specified, removing duplicated points, and removing points outside specified spatial polygon boundaries.

Usage

clean_coordinates(
  df,
  study_area,
  overlapping = FALSE,
  decimal_digits = NULL,
  coords = c("decimalLongitude", "decimalLatitude"),
  by_timestamp = TRUE,
  seed = NULL
)

Value

A cleaned data frame containing presence/absence data with valid coordinates.

Arguments

df

A dataframe object with rows representing points. Coordinates are in WGS84 (EPSG:4326) coordinate system.

study_area

A spatial polygon in WGS84 (EPSG:4326) representing the boundaries within which coordinates should be kept.

overlapping

Logical indicating whether points overlapping the polygon should be removed (TRUE) or kept (FALSE).

decimal_digits

An integer specifying the number of decimal places to which coordinates should be rounded.

coords

Character vector specifying the column names for longitude and latitude.

by_timestamp

If TRUE, clean coordinates taking into account different time periods defined in the column `timestamp`.

seed

Optional; an integer seed for reproducibility of results.

Details

This function takes a data frame containing presence/absence data with longitude and latitude coordinates, a spatial polygon representing boundaries within which to keep points, and parameters for rounding coordinates and handling duplicated points. It returns a cleaned data frame with valid coordinates within the specified boundaries.