Removes or flags non-numeric and not available coordinates as well as lat >90, lat <-90, lon > 180 and lon < -180 are flagged.

cc_val(
  x,
  lon = "decimalLongitude",
  lat = "decimalLatitude",
  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”.

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

Details

This test is obligatory before running any further tests of CoordinateCleaner, as additional tests only run with valid coordinates.

Note

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

See also

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

Examples


x <- data.frame(species = letters[1:10], 
                decimalLongitude = c(runif(106, -180, 180), NA, "13W33'", "67,09", 305), 
                decimalLatitude = runif(110, -90,90))
                
cc_val(x)
#> Testing coordinate validity
#> Removed 4 records.
#>     species decimalLongitude decimalLatitude
#> 1         a       26.8352674      -66.023696
#> 2         b      -36.1486127      -38.991989
#> 3         c      164.3511845       47.426976
#> 4         d      -96.1993214      -76.420631
#> 5         e      179.0695005      -81.612435
#> 6         f       39.0776463      -45.088302
#> 7         g        8.7861454       82.432528
#> 8         h       31.0472532       18.807471
#> 9         i     -152.2322543       19.563285
#> 10        j      125.5061298       55.408408
#> 11        a      -15.3088693       48.357957
#> 12        b     -144.8628890        8.942128
#> 13        c       97.1555798      -82.197269
#> 14        d       -4.5878925      -13.026399
#> 15        e     -126.5428915      -27.141443
#> 16        f       61.8726216      -41.110479
#> 17        g     -147.2990512      -38.928435
#> 18        h      125.6114344      -57.073553
#> 19        i      -68.4696110       11.142735
#> 20        j      -40.0543881       53.173485
#> 21        a     -124.6277199       19.225528
#> 22        b      -73.9517056       58.856344
#> 23        c     -167.5640863      -11.258338
#> 24        d      140.9751805      -73.434286
#> 25        e      166.5567659       11.526959
#> 26        f     -173.8984984      -28.627641
#> 27        g       15.1147288       42.975707
#> 28        h      106.9112043      -43.024534
#> 29        i      -67.8409988       15.917053
#> 30        j      -28.9791373       57.880299
#> 31        a       77.8776214       75.612526
#> 32        b       45.4831309      -38.312354
#> 33        c       16.5637888       37.185555
#> 34        d      137.5834468      -66.845471
#> 35        e     -128.6706466       16.913048
#> 36        f      109.4100048       27.274455
#> 37        g      169.4092333      -26.306841
#> 38        h       70.2829875      -63.032950
#> 39        i     -156.0296900       60.799909
#> 40        j      114.2376447       65.297994
#> 41        a       88.4832417      -11.715724
#> 42        b      121.4540083      -84.608926
#> 43        c      -13.9798487       32.231453
#> 44        d      -64.4522013       71.620670
#> 45        e       54.9856807       16.350084
#> 46        f       -6.4817043       38.803886
#> 47        g      -13.6183596       51.692665
#> 48        h      110.0212045       16.808644
#> 49        i       95.5624412      -80.019187
#> 50        j      102.1866668       41.274482
#> 51        a       90.7918155       50.142451
#> 52        b       15.6140473       65.201208
#> 53        c      -59.6049836      -61.079238
#> 54        d     -132.4661355      -45.291386
#> 55        e      149.5020779      -82.540734
#> 56        f      -31.4682765       76.535444
#> 57        g       50.3368818       87.624374
#> 58        h      -95.2711190       63.445227
#> 59        i       -6.6967396      -73.047896
#> 60        j     -174.0967460      -76.981747
#> 61        a      -72.3691496       44.907920
#> 62        b        0.2823836      -35.918371
#> 63        c      -79.3227578      -82.332069
#> 64        d      115.9546753        3.297336
#> 65        e      -48.0011899      -86.725206
#> 66        f       56.4674444        6.181845
#> 67        g        1.5889938      -20.717128
#> 68        h      144.1296840      -60.530056
#> 69        i     -131.6172448      -63.371423
#> 70        j      -13.0820058      -32.560091
#> 71        a       -1.0251298       47.499642
#> 72        b       66.3159098      -28.465545
#> 73        c      105.1897149      -32.683900
#> 74        d     -117.1290362      -14.382995
#> 75        e      -85.7108025      -48.830452
#> 76        f      176.6156098      -86.569770
#> 77        g       81.3246362       41.079035
#> 78        h      123.2965843      -42.111689
#> 79        i      -33.5554227      -15.685026
#> 80        j      -85.1469220      -36.106250
#> 81        a      -11.0279480       38.308105
#> 82        b     -163.1156903       33.500657
#> 83        c      -41.8787416       58.546038
#> 84        d     -179.1943632       88.584156
#> 85        e      139.4019347       79.889708
#> 86        f       96.7367885      -36.738170
#> 87        g      104.6365051       39.826347
#> 88        h       68.9828606       22.572340
#> 89        i       28.1190281      -37.544578
#> 90        j      115.4051802       26.607661
#> 91        a       27.2075826       58.673780
#> 92        b       36.3651814      -31.527431
#> 93        c      172.7600440       61.133898
#> 94        d      -77.9890409       52.737925
#> 95        e      -50.1120653      -80.725440
#> 96        f       59.7927653      -69.114684
#> 97        g      -52.1320895       79.147228
#> 98        h     -162.5313857      -82.756413
#> 99        i       41.5066590       66.254808
#> 100       j     -170.2899859       48.574637
#> 101       a     -178.2033712       75.561077
#> 102       b      -70.4423736       56.106249
#> 103       c     -145.5828631      -85.639238
#> 104       d      -70.4660162       58.804614
#> 105       e       83.8401064      -50.832513
#> 106       f      112.6743199      -87.313739
cc_val(x, value = "flagged")
#> Testing coordinate validity
#> Flagged 4 records.
#>   [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [37]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [49]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [61]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [73]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [85]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#>  [97]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
#> [109] FALSE FALSE