Convert flags to CoordinateCleaner's spatialvalid format
Source:R/spatialvalid.R
as_spatialvalid.RdReturns flagged records in the layout that CoordinateCleaner's
clean_coordinates() and clean_fossils() return with
value = "spatialvalid", so code written for that object (its summary()
and plot() methods, filters on .summary) runs unchanged. The record
columns come first, then one logical column per test, TRUE when the
record passes, then .summary, TRUE when it passes every test given.
Arguments
- x
A flagged data frame (
occ_flags) fromflag_occurrences(), or flags written to disk (anocc_flaggedobject or its directory). Flags on disk are read into memory with theirkeepcolumns as the record columns.- tests
Tests to include, from those
xwas flagged with; default all of them..summaryis then the complement of the rule made of these tests.
Value
A data frame of class c("spatialvalid", "data.frame"), carrying
the reference and layout version of the flags as attributes
occ_reference and occ_layout_version.
Details
Each test takes the column name CoordinateCleaner uses for it (.cap for
capital, .otl for outlier, see the spatialvalid column of
flag_tests()); a test without one there is written as .<test>, for
example .issue_coordinate. The columns are decoded from the flags word,
so a record whose flag word is NA is NA in every column.
Examples
x <- data.frame(species = c("a", "a", "b"),
decimalLongitude = c(0, 16.37, 10),
decimalLatitude = c(0, 48.21, 50))
sv <- as_spatialvalid(flag_occurrences(x))
sv
sv[sv$.summary, ]