coord_clean: Clean lat/long coordinates in occurrence data sets

View source: R/coord_clean.R

coord_cleanR Documentation

Clean lat/long coordinates in occurrence data sets

Description

Removes records that do not pass various coordinate validity tests.

Usage

coord_clean(
  data,
  lat = "decimalLatitude",
  lon = "decimalLongitude",
  country = "country",
  tests = "all",
  centroid_dis = 100,
  round_digits = 4
)

Arguments

data

Data.frame of occurrence data (e.g. MyCoPortal, GBIF) that includes decimal latitude and longitude

lat

Character string specifying the decimal latitude column. Default is "decimalLatitude" (i.e., the Darwin Core standard).

lon

Character string specifying the decimal longitude column. Default is "decimalLongitude" (i.e., the Darwin Core standard).

country

Character string specifying the name of the country column. Default is "country" (i.e., the Darwin Core standard).

tests

Character vector specifying the coordinate cleaning tests to perform. Options include: "zero", "equal", "countries", "centroids", "all". Default is "all".

centroid_dis

Numeric specifying the distance threshold (in meters) to use for the centroid test. Default is 100.

round_digits

Integer specifying the number of decimal places to use for rounding coordinates. Default is 4. If NULL, no rounding is performed.

Details

The following tests are automatically done:

non-numeric

lat or lon are not numeric or cannot be converted to numeric

non-valid

lat or lon are invalid numbers (i.e., lat>90, lat<-90, lon>180, lon<-180)

The following tests can be selected:

zero

lat and lon are both zero

equal

lat and lon are equal

countries

point is outside the bounds of the country listed

centroid

distance between point and country centroid is less than or equal to the centroid_dis specified

Value

Data.frame containing records from the input data set that passed the coordinate cleaning tests. Number of records removed at each step is printed to the console.

Examples

library(fungarium)
data(agaricales_updated) #import sample data set
clean <- coord_clean(agaricales_updated) #clean coordinates


hjsimpso/fungarium documentation built on Aug. 23, 2023, 3:59 p.m.