Removes or flags records within a radius around the geographic centroids of political countries and provinces. Poorly geo-referenced occurrence records in biological databases are often erroneously geo-referenced to centroids.

cc_cen(
  x,
  lon = "decimalLongitude",
  lat = "decimalLatitude",
  species = "species",
  buffer = 1000,
  geod = TRUE,
  test = "both",
  ref = NULL,
  verify = FALSE,
  value = "clean",
  verbose = TRUE
)

Arguments

x

data.frame. Containing geographical coordinates and species names.

lon

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

lat

character string. The column with the latitude coordinates. Default = “decimalLatitude”.

species

character string. The column with the species identity. Only required if verify = TRUE.

buffer

numerical. The buffer around each province or country centroid, where records should be flagged as problematic. Units depend on geod. Default = 1 kilometre.

geod

logical. If TRUE the radius around each capital is calculated based on a sphere, buffer is in meters and independent of latitude. If FALSE the radius is calculated assuming planar coordinates and varies slightly with latitude. Default = TRUE. See https://seethedatablog.wordpress.com/ for detail and credits.

test

a character string. Specifying the details of the test. One of c(“both”, “country”, “provinces”). If both tests for country and province centroids.

ref

SpatVector (geometry: polygons). Providing the geographic gazetteer. Can be any SpatVector (geometry: polygons), but the structure must be identical to countryref. Default = countryref.

verify

logical. If TRUE records are only flagged if they are the only record in a given species flagged close to a given reference. If FALSE, the distance is the only criterion

value

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 (“flagged”), with TRUE = test passed and FALSE = test failed/potentially problematic . Default = “clean”.

Note

See https://ropensci.github.io/CoordinateCleaner/ for more details and tutorials.

See also

Other Coordinates: cc_aohi(), cc_cap(), cc_coun(), cc_dupl(), cc_equ(), cc_gbif(), cc_inst(), cc_iucn(), cc_outl(), cc_sea(), cc_urb(), cc_val(), cc_zero()

Examples


x <- data.frame(species = letters[1:10], 
                decimalLongitude = c(runif(99, -180, 180), -47.92), 
                decimalLatitude = c(runif(99, -90,90), -15.78))
cc_cen(x, geod = FALSE)
#> Testing country centroids
#> Removed 0 records.
#>     species decimalLongitude decimalLatitude
#> 1         a       -80.117973     84.73346278
#> 2         b      -150.314870     -4.96314263
#> 3         c       114.164298     -9.75687656
#> 4         d      -179.501954    -34.32877343
#> 5         e       100.880128     87.69825437
#> 6         f        97.653524    -31.08186764
#> 7         g       128.583223     -6.15427041
#> 8         h       -73.025403    -48.01443740
#> 9         i       -57.643663    -87.11257262
#> 10        j       160.709490     11.13592226
#> 11        a       -21.526743     73.09101444
#> 12        b      -106.848146    -80.31919001
#> 13        c        24.294796    -82.62730182
#> 14        d      -170.466418     -5.04496987
#> 15        e        44.695590     37.18092000
#> 16        f       141.397599    -17.30995644
#> 17        g      -155.490826     26.40372074
#> 18        h      -107.814463      4.59085596
#> 19        i       -26.100594    -52.48535566
#> 20        j       169.709933    -70.70254130
#> 21        a      -168.139657     37.44108883
#> 22        b        76.581345     31.51530876
#> 23        c         7.764866    -80.78003534
#> 24        d        86.649973     32.90821271
#> 25        e        62.707324     80.42738705
#> 26        f        50.874331     39.03524831
#> 27        g      -151.298703     19.89860498
#> 28        h       135.906451     61.30135022
#> 29        i       132.512965    -12.80095002
#> 30        j       167.434586     76.76003720
#> 31        a       -98.363469    -22.62017336
#> 32        b      -107.398760    -25.52855516
#> 33        c         6.885513    -57.87162099
#> 34        d      -177.170159    -11.47118174
#> 35        e      -150.857791     33.49739152
#> 36        f       -36.519207     -4.22892299
#> 37        g       126.549355    -53.96362037
#> 38        h       -68.119510     21.01818438
#> 39        i       -37.123970    -89.34731633
#> 40        j       -91.204867     82.79178652
#> 41        a      -153.831221     17.02384563
#> 42        b      -120.950591    -36.02571492
#> 43        c      -142.509162     34.38694493
#> 44        d       132.141901    -85.23362737
#> 45        e       112.841568     78.41850901
#> 46        f      -157.678945    -13.67248292
#> 47        g        86.245317     -0.19446070
#> 48        h        35.658711     -3.86531645
#> 49        i        88.153584    -19.67081947
#> 50        j      -177.490025     31.27194636
#> 51        a      -108.693367    -14.41911230
#> 52        b       164.451001    -63.79531573
#> 53        c      -113.357662     20.21660466
#> 54        d       -29.871296    -22.67649744
#> 55        e      -108.431172     70.06840083
#> 56        f       171.152162      4.83691917
#> 57        g        28.443290    -10.95948487
#> 58        h      -147.960564    -71.57354346
#> 59        i      -107.091535     79.95430975
#> 60        j       -36.395100     26.56643552
#> 61        a       -41.164075     48.20956907
#> 62        b      -179.801978    -21.46838197
#> 63        c       -92.028851     54.57875215
#> 64        d       176.201852     63.85686748
#> 65        e      -116.814253      8.35694329
#> 66        f      -147.116536      0.63303293
#> 67        g        -1.393278     88.78517716
#> 68        h       145.147163     22.10401618
#> 69        i       -54.926877    -15.33905384
#> 70        j      -149.956991    -75.43789620
#> 71        a      -108.384318    -28.40116376
#> 72        b       178.412941     53.10053639
#> 73        c       178.411017    -80.40162661
#> 74        d       103.278296    -19.96637229
#> 75        e       -20.953208     -1.68670538
#> 76        f        40.383791     73.69891264
#> 77        g      -170.101908    -16.41104951
#> 78        h        -5.078075     -0.07514565
#> 79        i        -8.359452    -41.37990199
#> 80        j       -61.785090     -9.58382123
#> 81        a        48.752210    -74.84960445
#> 82        b       -51.982581     62.52990307
#> 83        c        77.737603     22.25423091
#> 84        d       -87.433279     -4.38172647
#> 85        e      -162.894112     77.88373404
#> 86        f        73.267237    -60.24757274
#> 87        g        24.558292     76.52620800
#> 88        h       119.963393     69.76859688
#> 89        i      -110.345063    -61.32852158
#> 90        j        74.815371     62.27256523
#> 91        a       -87.026155      7.89889194
#> 92        b       104.278707      9.00750533
#> 93        c         8.051585    -29.77534766
#> 94        d      -139.279972     66.84292224
#> 95        e       -49.402088     81.41322752
#> 96        f       115.020627      7.51022694
#> 97        g       -78.040879    -64.33531506
#> 98        h       -43.440122    -63.92073804
#> 99        i       -64.159266     -6.76189046
#> 100       j       -47.920000    -15.78000000

if (FALSE) {
cc_inst(x, value = "flagged", buffer = 50000) #geod = T
}