Skip to contents

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

Usage

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_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       145.560372     -35.2667631
#> 2         b       165.935607      64.8327657
#> 3         c       -45.708725     -24.2856443
#> 4         d      -174.979755     -11.6073083
#> 5         e        86.947494     -52.9793631
#> 6         f       171.741207      56.8133802
#> 7         g       148.623960      75.8020291
#> 8         h       -49.993071     -45.7645361
#> 9         i      -129.813454     -31.8486620
#> 10        j       169.425349      46.0628788
#> 11        a      -178.058062     -58.3728793
#> 12        b        33.674386      36.4734825
#> 13        c       156.122105      17.3951399
#> 14        d       168.780195     -53.2506417
#> 15        e       160.330394     -77.6607430
#> 16        f        33.923735      41.1281658
#> 17        g        81.254369      71.3394443
#> 18        h       116.803740     -28.7893747
#> 19        i       -63.398587     -32.2130996
#> 20        j        14.361635      46.5408877
#> 21        a        21.054837     -58.7134789
#> 22        b        36.419591     -16.9883020
#> 23        c        10.974077     -45.5331688
#> 24        d        72.894875      33.8914530
#> 25        e       -63.592490      44.1618317
#> 26        f       147.209583      21.3417426
#> 27        g       -52.232991      50.7783378
#> 28        h       -12.336058     -26.2694504
#> 29        i        -2.552935      12.0603279
#> 30        j        26.311312     -73.9120037
#> 31        a        74.451150     -45.3390239
#> 32        b       -70.270182     -30.5673994
#> 33        c      -104.021519      10.2509470
#> 34        d       126.322122     -68.6626915
#> 35        e        98.673223     -83.2408883
#> 36        f       -67.293501     -27.4257555
#> 37        g       -80.586804     -35.4663103
#> 38        h        82.335797     -44.0750589
#> 39        i       -41.909879      47.0516189
#> 40        j       -56.611890      27.1365189
#> 41        a      -101.783576      19.4252269
#> 42        b       -43.790971      60.9453011
#> 43        c       -71.953693       7.9329349
#> 44        d        88.898523      -8.0143214
#> 45        e       168.864487      16.7805293
#> 46        f        72.864327      49.2089193
#> 47        g       158.308527      38.1787012
#> 48        h       161.458373     -69.6611154
#> 49        i      -175.133555      72.6219142
#> 50        j       -88.827485     -75.1723651
#> 51        a       -93.218310      57.0876651
#> 52        b      -104.150654     -89.5007272
#> 53        c       132.844079      87.3580560
#> 54        d        83.413067       0.3177831
#> 55        e       -88.738472     -65.9216676
#> 56        f       167.676994     -18.8595342
#> 57        g       174.886857      -7.2138830
#> 58        h       -87.988830     -65.1277401
#> 59        i        12.759553      52.5133706
#> 60        j      -126.760395     -37.6479313
#> 61        a       114.721697     -10.3384636
#> 62        b       161.233025     -17.3589221
#> 63        c       105.564973      -1.5774868
#> 64        d        71.251578      51.7217850
#> 65        e      -121.711620     -67.6867619
#> 66        f        65.646746     -13.9551642
#> 67        g        47.135418      76.5593178
#> 68        h       -49.171727     -89.0354617
#> 69        i        -7.836448      64.6347629
#> 70        j        99.931033      76.9518875
#> 71        a       134.013902      -1.1861422
#> 72        b       157.824261      84.9037165
#> 73        c       -75.406456      -2.1378171
#> 74        d      -126.325157      60.7932450
#> 75        e       -92.996714      51.9748871
#> 76        f       153.777611      46.7923536
#> 77        g      -129.127161     -73.2681729
#> 78        h       -87.358695     -33.1423040
#> 79        i       -95.070744      18.3261844
#> 80        j      -126.894573      12.7516940
#> 81        a      -168.644684     -55.8347843
#> 82        b      -100.864836     -49.1421937
#> 83        c       137.353609     -36.0152778
#> 84        d       136.643540      13.7683252
#> 85        e       109.519178     -13.7202745
#> 86        f       -70.027387      58.4895140
#> 87        g       101.118757      13.5616063
#> 88        h       -61.839624      84.9551064
#> 89        i       -93.758132      67.3928736
#> 90        j        83.149369      74.6626057
#> 91        a        21.096068      62.8213708
#> 92        b      -142.203262     -25.4030218
#> 93        c       -38.936799      75.3201379
#> 94        d       -54.143843      45.3571747
#> 95        e       143.930952     -48.0920872
#> 96        f       -38.984900      65.9320675
#> 97        g      -146.104848     -35.0908732
#> 98        h       129.639437     -17.3901463
#> 99        i        47.261816     -68.0073045
#> 100       j       -89.272194     -28.7095792
#> 101       a       -93.437969      64.1429315
#> 102       b       -60.870955      24.4631309
#> 103       c       142.535850      31.3742623
#> 104       d       130.866474      25.1022194
#> 105       e        18.436126     -28.2732104
#> 106       f        15.919418     -13.3100905
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