
Check if the records fall in the country assigned in the metadata
Source:R/check_countries.R
check_countries.RdCheck if the records fall in the country assigned in the metadata
Usage
check_countries(
occ,
long = "decimalLongitude",
lat = "decimalLatitude",
country_column,
distance = 5,
try_to_fix = FALSE,
progress_bar = FALSE,
verbose = TRUE
)Arguments
- occ
(data.frame or data.table) a dataset with occurrence records, preferably with country information standardized using
standardize_countries().- long
(character) column name with longitude. Default is
'decimalLongitude'.- lat
(character) column name with latitude. Default is
'decimalLatitude'.- country_column
(character) column name containing the country information.
- distance
(numeric) maximum distance (in kilometers) a record can fall outside the country assigned in the
country_column. Default is5.- try_to_fix
(logical) whether to check if coordinates are inverted or transposed (see
fix_countries()for details). IfTRUE, coordinates identified as inverted or transposed will be corrected. Default isFALSE.- progress_bar
(logical) whether to display a progress bar during processing. If
TRUE, the'pbapply'package must be installed. Default isFALSE.- verbose
(logical) whether to print messages about function progress. Default is
TRUE.
Value
The original occ object (data.frame or data.table) with an additional
column (correct_country) indicating whether each record falls within the
country specified in the metadata (TRUE) or not (FALSE). As with all
other flagging functions in RuHere, TRUE indicates that the record passed
this test and is eligible for retention; FALSE indicates it failed and is
flagged as potentially problematic, and can be removed using
remove_flagged().
Examples
# Load example data
data("occurrences", package = "RuHere")
# Standardize country names
occ_country <- standardize_countries(occ = occurrences,
return_dictionary = FALSE)
# Check whether records fall within assigned countries
occ_country_checked <- check_countries(occ = occ_country,
country_column = "country_suggested")
#> Testing countries...
#> 51 records fall in wrong countries