Skip to contents

Flags records whose coordinates fall outside the Natural Earth 1:50 million country polygon named by their country code. The code is compared with the polygon's ISO 3166-1 alpha-2 code, its alpha-3 code and the Natural Earth ADM0_A3 code, case-insensitively. Records without a code, and records at sea, are flagged.

Usage

clean_country_mismatch(x, ...)

Arguments

x

A data frame of occurrence records.

...

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.

Fields

lon, lat, country.

CoordinateCleaner

Equivalent to cc_coun(), which compares alpha-3 codes only; for alpha-3 codes present in Natural Earth the flags are identical. GBIF's countryCode is alpha-2 and works here without conversion.

Custom gazetteer

gazetteers = list(country_mismatch = polygons), an sf or sfc object of country polygons with a code column; see flag_occurrences().

Examples

x <- data.frame(decimalLongitude = 16.37, decimalLatitude = 48.21,
                countryCode = c("AT", "AUT", "DE", NA))
flag_occurrences(x, tests = "country_mismatch")$flag_country_mismatch
clean_country_mismatch(x)