Learn R Programming

CoordinateCleaner (version 1.0-7)

cc_urb: Flag Records Inside Urban Areas

Description

Flags records from inside urban areas, based on a geographic gazetteer. Often records from large databases span substantial time periods (centuries) and old records might represent habitats which today are replaced by city area.

Usage

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

Arguments

x

a data.frame. Containing geographical coordinates and species names.

lon

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

lat

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

ref

a SpatialPolygonsDataframe. Providing the geographic gazetteer with the urban areas. See details.

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”.

Details

No default reference is provided with the package due to the large file size of such (global) gazetteers. You can download an example here: https://github.com/azizka/CoordinateCleaner/blob/master/extra_gazetteers/urbanareas.rda. Can be any SpatialPolygonsDataframe, but the structure must be identical to urbanareas.

Examples

Run this code
# NOT RUN {
# load reference 
#See details section on where to download the reference data
load("extra_gazetteers/urbanareas.rda")

x <- data.frame(species = letters[1:10], 
                decimallongitude = runif(100, -180, 180), 
                decimallatitude = runif(100, -90,90))
                
cc_urb(x, ref = urbanareas)
cc_urb(x, value = "flags", ref = urbanareas)
# }

Run the code above in your browser using DataLab