Skip to contents

Flags records within 10 km of a country capital, measured as WGS84 geodesic distance (closed ball: a record at exactly the buffer distance is flagged). Candidates are found with a kd-tree on the unit sphere and decided with the Vincenty inverse formula.

Usage

clean_capital(x, buffer = 10000, ...)

Arguments

x

A data frame of occurrence records.

buffer

Buffer distance of the test, in the unit of its Buffer section; the default is the test's default buffer.

...

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.

Details

The default gazetteer contains the capital "geographic coordinates" of the CIA World Factbook (public domain; 232 points, one per country profile, through the factbook.json mirror retrieved 2026-10-11), the source CoordinateCleaner's capitals are taken from. The column extension marks the 243 Natural Earth populated places of the classes admin-0 capital, alternative capital and admin-0 region capital (dependent territories), which add the second capitals of countries that have several (Cape Town, Sucre, Naypyidaw); passing the points with extension FALSE as gazetteers = list(capital = ...) leaves them out. See reference_info().

Fields

lon, lat.

Buffer

buffers = list(capital = 10000), in metres.

CoordinateCleaner

Equivalent to cc_cap(). CoordinateCleaner draws the buffer as a 72-gon with vertices on the circle, whose edge lies at 99.9 % of the buffer between vertices; records in that band (within 9.5 m of the 10 km edge) are flagged here and may not be there. Of its 225 capital points, 221 are Factbook points of the default gazetteer rounded to 0.01 degree, which moves them by up to 523 m. The other four hold values the Factbook has since revised: Bujumbura for Burundi, whose capital it now gives as Gitega; Buenos Aires at 58 40 W, 27 km west of the city, now 58 22 W; Melekeok for Palau, now Ngerulmud; and Rangoon, 1.8 km from its present coordinates. With reference = "CoordinateCleaner" its countryref capitals are used.

Custom gazetteer

gazetteers = list(capital = points), a data frame of longitude and latitude; see flag_occurrences().

Examples

x <- data.frame(decimalLongitude = c(16.37, 16.51), decimalLatitude = c(48.21, 48.25))
flag_occurrences(x, tests = "capital")$flag_capital
flag_occurrences(x, tests = "capital", buffers = list(capital = 20000))$flag_capital
g <- reference_points("capital")
flag_occurrences(x, tests = "capital",
                 gazetteers = list(capital = g[!g$extension, ]))$flag_capital
clean_capital(x, buffer = 20000)