Test: degree-minute conversion errors in a dataset
Source:R/clean.R, R/test-docs.R
test_dataset_ddmm.RdFlags every record of a dataset whose coordinates look converted from
degrees and minutes as if they were decimal degrees, which leaves no decimal
part above .59. The decimal parts of each dataset's distinct coordinates are
placed on a mat_size x mat_size grid; a binomial test compares the share
of filled cells with both decimals below .6 with its expected share, and
the dataset fails when the excess is significant (p < pvalue) and larger
than diff times the expected share. Datasets spanning less than
min_span degrees in longitude or latitude are not tested.
Arguments
- x
A data frame of occurrence records.
- pvalue, diff, mat_size, min_span
Options of the test, as in Settings; the defaults are in the usage line.
- ...
Further arguments to
flag_occurrences():columns,reference,gazetteers,land_scale.
Value
clean_<test>(): the rows of x the test does not flag, with the
columns of x unchanged. See keep_unflagged(), Cleaning functions.
Settings
settings = list(dataset_ddmm = list(...)) with
pvalue (0.025), diff (1), mat_size (1000) and min_span (2).
CoordinateCleaner
Equivalent to cd_ddmm(); identical flags.
Records without a dataset key are not flagged here; cd_ddmm() flags
them.
See also
flag_occurrences(), flag_tests()
Other tests:
clean_age_equal(),
clean_age_outlier(),
clean_age_range_outlier(),
clean_aohi(),
clean_basis_fossil(),
clean_capital(),
clean_centroid(),
clean_country_mismatch(),
clean_dataset_rounded(),
clean_duplicate(),
clean_equal(),
clean_establishment_introduced(),
clean_gbif_headquarters(),
clean_institution(),
clean_invalid(),
clean_issue_coordinate(),
clean_outlier(),
clean_range(),
clean_sea(),
clean_sea_nonmarine(),
clean_spatiotemporal_outlier(),
clean_urban(),
clean_zero()
Examples
set.seed(2)
ddmm <- function(n) floor(runif(n, 0, 20)) + sample(0:59, n, TRUE) / 100
x <- data.frame(datasetKey = rep(c("ok", "ddmm"), each = 300),
decimalLongitude = c(runif(300, 0, 20), ddmm(300)),
decimalLatitude = c(runif(300, 0, 20), ddmm(300)))
tapply(flag_occurrences(x, tests = "dataset_ddmm")$flag_dataset_ddmm, x$datasetKey, all)
table(clean_dataset_ddmm(x)$datasetKey)