
Check if the records fall in the state assigned in the metadata
Source:R/check_states.R
check_states.RdCheck if the records fall in the state assigned in the metadata
Usage
check_states(
occ,
long = "decimalLongitude",
lat = "decimalLatitude",
state_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 state information standardized using
standardize_states().- long
(character) column name with longitude. Default is
'decimalLongitude'.- lat
(character) column name with latitude. Default is
'decimalLatitude'.- state_column
(character) column name containing the state information.
- distance
(numeric) maximum distance (in kilometers) a record can fall outside the state assigned in the
state_column. Default is5.- try_to_fix
(logical) whether to check if coordinates are inverted or transposed (see
fix_states()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_state) indicating whether each record falls within the
state 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")
# Subset occurrences for Araucaria angustifolia
occ <- occurrences[occurrences$species == "Araucaria angustifolia", ]
# Standardize country names
occ_country <- standardize_countries(occ = occ,
return_dictionary = FALSE)
# Standardize state names
occ_state <- standardize_states(occ = occ_country,
country_column = "country_suggested",
return_dictionary = FALSE)
# Check whether records fall within assigned states
occ_state_checked <- check_states(occ = occ_state,
state_column = "state_suggested")
#> Testing states...
#> 8 records fall in wrong states