Learn R Programming

CoordinateCleaner (version 1.0-7)

cc_coun: Flag Coordinates Outside their Reported Country

Description

Identifies mismatches between geographic coordinates and additional country information (usually this information is reliably reported with specimens). Such a mismatch can occur for example, if latitude and longitude are switched.

Usage

cc_coun(x, lon = "decimallongitude", lat = "decimallatitude", 
        iso3 = "countrycode", value = "clean", ref = NULL, verbose = TRUE)

Arguments

x

a data.frame. Containing geographical coordinates and species names, and a country assignment.

lon

a character string. The column with the longitude coordinates. Default = “decimallongitude”.

lat

a character string. The column with the longitude coordinates. Default = “decimallatitude”.

iso3

a character string. The column with the country assignment of each record in three letter ISO code. Default = “countrycode”.

ref

a SpatialPolygonsDataframe. Providing the geographic gazetteer. Can be any SpatialPolygonsDataframe, but the structure must be identical to countryref. Default = countryref

value

a character string. Defining the output value. See value.

verbose

logical. If TRUE reports the name of the test and the number of records flagged.

Value

Depending on the ‘value’ argument, either a data.frame containing the records considered correct by the test (“clean”) or a logical vector, with TRUE = test passed and FALSE = test failed/potentially problematic (“flags”). Default = “clean”.

Examples

Run this code
# NOT RUN {
x <- data.frame(species = letters[1:10], 
                decimallongitude = runif(100, -20, 30), 
                decimallatitude = runif(100, 35,60),
                countrycode = "RUS")

cc_coun(x, value = "flags")#non-terrestrial records are not flagged! Use cc_sea for these
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab