
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) a dataset with occurrence records, preferably with country information standardized using
standardize_countries().- long
(character) column name with longitude. Default is 'decimalLongitude'.
- lat
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 is
FALSE.- verbose
(logical) whether to print messages about function progress. Default is
TRUE.
Value
The original occ data.frame with an additional column (correct_country)
indicating whether each record falls within the country specified in the
metadata (TRUE) or not (FALSE).
Examples
# Load example data
data("occurrences", package = "RuHere") #Import data example
# 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")
#> Warning: The following countries listed in the 'country_suggested' column were absent in the world map used for validation: NA
#> Testing countries...
#> 54 records fall in wrong countries