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 -52.270031 -57.4235737
#> 2 b 110.610979 89.3614883
#> 3 c -52.996008 26.1199695
#> 4 d 91.125391 75.2577151
#> 5 e 146.934390 53.1117802
#> 6 f -23.261325 74.3574753
#> 7 g -100.711030 -19.6992751
#> 8 h -166.614406 -25.6679112
#> 9 i 71.299467 20.5850932
#> 10 j -126.059755 -55.3606657
#> 11 a 15.277541 -77.0690705
#> 12 b 106.838051 -34.8780713
#> 13 c 79.064881 -58.5762579
#> 14 d 82.148276 69.7970023
#> 15 e -162.786182 -0.3873195
#> 16 f -17.504743 34.9034565
#> 17 g 105.937185 67.3588848
#> 18 h 116.864037 -86.7443806
#> 19 i -104.741437 -21.2423301
#> 20 j -119.445648 2.4467444
#> 21 a 172.898721 -81.4999213
#> 22 b 36.241203 54.5571198
#> 23 c -125.396532 24.1356481
#> 24 d -74.614076 48.8390785
#> 25 e -18.698176 0.3174737
#> 26 f 116.606817 38.0319774
#> 27 g 168.985559 -73.4582906
#> 28 h -73.652701 -70.9364206
#> 29 i -96.231693 -49.5155013
#> 30 j -62.826826 -14.8205604
#> 31 a -143.866037 -28.0776478
#> 32 b -61.118870 29.5570722
#> 33 c -110.664467 -10.1945391
#> 34 d -83.205491 -34.8869588
#> 35 e 138.070564 -41.5177188
#> 36 f 61.424338 -41.3232129
#> 37 g -153.244416 -72.4158625
#> 38 h 66.711313 88.5707913
#> 39 i 36.293613 -71.1852230
#> 40 j 74.210571 -11.7920771
#> 41 a -11.460236 33.2437627
#> 42 b -176.044344 -30.6321259
#> 43 c 101.986450 -18.0823157
#> 44 d 43.867187 35.8481775
#> 45 e 131.781146 -46.3458405
#> 46 f 151.146841 -85.0436852
#> 47 g -62.856387 -77.3837960
#> 48 h 149.674344 -85.7334102
#> 49 i -151.003833 -52.8118012
#> 50 j 127.986365 35.7995378
#> 51 a -70.189568 86.6490413
#> 52 b 85.090695 50.6972844
#> 53 c 158.746525 18.9854229
#> 54 d 129.968365 -52.4948922
#> 55 e -48.898756 47.4621290
#> 56 f 148.508454 57.3814794
#> 57 g 91.051993 47.0002157
#> 58 h 50.933667 59.1528817
#> 59 i 106.362119 -88.4683279
#> 60 j 174.589821 -74.0121775
#> 61 a 44.052926 75.5784225
#> 62 b 19.917535 24.9113612
#> 63 c 165.983941 -14.9425643
#> 64 d 149.630298 36.3663946
#> 65 e 37.179216 -61.0152975
#> 66 f -67.840522 -21.9762296
#> 67 g 19.854765 85.5210270
#> 68 h 157.535188 -17.3600679
#> 69 i -48.586625 40.2766736
#> 70 j -58.092373 -20.6658217
#> 71 a 97.086082 -19.9640788
#> 72 b -71.516771 -66.6644820
#> 73 c 46.670744 -38.7448736
#> 74 d 108.899901 -66.4660992
#> 75 e 15.204803 -4.6711850
#> 76 f 47.159124 86.4016542
#> 77 g -111.676007 -59.6987217
#> 78 h -106.757032 -57.3231120
#> 79 i 154.206453 68.2090289
#> 80 j -31.160356 31.7987943
#> 81 a -132.850841 1.3398504
#> 82 b -157.981318 -3.3464414
#> 83 c 138.986594 84.2975857
#> 84 d 33.195062 -45.3689806
#> 85 e 80.068387 -66.0933698
#> 86 f 4.461480 -77.7120934
#> 87 g -73.415285 -17.9597240
#> 88 h 50.320104 -27.4788716
#> 89 i 137.715634 -75.3576530
#> 90 j 160.614263 -82.7844119
#> 91 a 75.390003 -41.7765122
#> 92 b 152.503407 -2.7760158
#> 93 c -174.160227 18.6922297
#> 94 d -118.267816 -51.7174162
#> 95 e -102.963685 -75.5716997
#> 96 f 124.241468 -57.6262293
#> 97 g -92.404184 53.0927321
#> 98 h 5.418128 5.2566040
#> 99 i 130.747497 -6.0976205
#> 100 j -165.398877 70.5912706
#> 101 a -14.389839 43.5516965
#> 102 b -120.238255 47.4724478
#> 103 c 149.538362 61.9379609
#> 104 d -32.607424 36.9391482
#> 105 e 50.591584 80.7195993
#> 106 f -120.665372 -64.0274794
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