Removes or flags non-numeric and not available coordinates as well as lat >90, lat <-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.
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 139.960163 2.714213
#> 2 b 123.721268 -22.657575
#> 3 c 16.829869 -9.106877
#> 4 d -87.475574 68.669291
#> 5 e -18.748979 -6.057378
#> 6 f -154.092145 50.331887
#> 7 g 155.728509 67.072977
#> 8 h 105.130340 59.511856
#> 9 i -20.857225 68.541891
#> 10 j -74.829953 57.797704
#> 11 a -47.936709 82.706399
#> 12 b -82.537084 -9.734454
#> 13 c -7.653825 -49.793956
#> 14 d -124.640072 68.301082
#> 15 e 61.848143 40.702252
#> 16 f 23.056200 -22.624410
#> 17 g 149.891799 84.566549
#> 18 h 62.696210 33.149898
#> 19 i 120.825445 63.018706
#> 20 j 121.142716 17.834615
#> 21 a 56.506590 26.338155
#> 22 b -108.771322 -51.526303
#> 23 c -29.049704 -29.828181
#> 24 d -60.401778 36.859343
#> 25 e 117.801525 59.473390
#> 26 f 20.044293 77.175325
#> 27 g 136.674276 64.713726
#> 28 h 179.176341 -50.240781
#> 29 i -35.994489 17.985525
#> 30 j -97.214597 42.312640
#> 31 a -116.838666 -82.908861
#> 32 b 128.712597 -64.427014
#> 33 c 162.883340 72.825828
#> 34 d -165.059167 -9.214445
#> 35 e 7.709092 -75.013983
#> 36 f -1.200577 62.734172
#> 37 g 73.169808 54.933630
#> 38 h -125.320122 -72.062897
#> 39 i 39.738800 -78.048400
#> 40 j 178.337769 -65.169110
#> 41 a 158.782118 -11.986470
#> 42 b 3.839336 6.405068
#> 43 c 118.302086 -7.276883
#> 44 d -61.284064 28.683086
#> 45 e -11.977279 85.594805
#> 46 f -52.520214 -33.359126
#> 47 g 147.390954 15.159658
#> 48 h 103.459324 -35.247816
#> 49 i -64.658217 72.944551
#> 50 j 5.929590 -14.971455
#> 51 a -71.932542 57.624294
#> 52 b -75.327645 -8.083552
#> 53 c 124.070054 -80.050430
#> 54 d 17.060956 23.947601
#> 55 e 59.412852 82.763940
#> 56 f -153.876832 -43.766867
#> 57 g 103.970113 19.368338
#> 58 h 162.481070 7.088885
#> 59 i 31.700338 -77.571612
#> 60 j 127.563809 10.747840
#> 61 a 64.821221 -3.879421
#> 62 b 76.095520 -21.274453
#> 63 c -66.846793 -72.293926
#> 64 d -67.731123 -37.112276
#> 65 e 106.171120 -80.897574
#> 66 f 55.687000 -4.027367
#> 67 g 63.495481 20.490572
#> 68 h 2.623203 -79.648524
#> 69 i 46.413555 71.841252
#> 70 j 81.716962 -57.435524
#> 71 a -176.642746 -85.072467
#> 72 b 54.325299 28.994266
#> 73 c -139.610323 2.767326
#> 74 d -28.331888 -73.318219
#> 75 e -61.649311 3.142834
#> 76 f 161.673949 -27.877770
#> 77 g 10.513194 -84.518275
#> 78 h 118.734243 -30.055970
#> 79 i 128.440286 43.341888
#> 80 j 15.167338 57.273254
#> 81 a -76.190825 72.715443
#> 82 b -105.974456 -6.039954
#> 83 c 44.466590 85.481695
#> 84 d 65.104917 26.707479
#> 85 e -120.698272 -42.239505
#> 86 f 2.892955 -14.145330
#> 87 g -97.690531 79.584344
#> 88 h -166.841348 -45.985198
#> 89 i -30.712231 -58.274138
#> 90 j 26.051348 -63.679962
#> 91 a 56.629976 53.972749
#> 92 b -115.990012 80.519645
#> 93 c -151.914732 -3.842598
#> 94 d 156.380726 77.239124
#> 95 e 106.635341 1.608100
#> 96 f 13.440817 30.093730
#> 97 g 2.485761 -21.605509
#> 98 h -166.836198 -13.663325
#> 99 i -74.610386 -85.049406
#> 100 j 7.912243 -64.640550
#> 101 a -161.248144 63.579433
#> 102 b 26.988219 -23.467413
#> 103 c -127.501401 50.024589
#> 104 d -153.599722 -56.244761
#> 105 e 71.311984 -43.373158
#> 106 f 124.463493 17.619960
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