Removes or flags non-numeric and not available coordinates as well as lat >90, la <-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

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 175.854798 -79.431127 #> 2 b -78.380845 -25.494926 #> 3 c 19.480452 -3.710512 #> 4 d 140.430242 40.156518 #> 5 e -171.791260 35.352486 #> 6 f 63.967843 66.727900 #> 7 g -58.658473 37.585054 #> 8 h -129.169406 -26.135016 #> 9 i -53.076964 55.305489 #> 10 j -35.479852 -26.498004 #> 11 a 140.009167 45.562696 #> 12 b -67.458892 73.467195 #> 13 c -157.804305 -11.630662 #> 14 d 64.615055 -50.355515 #> 15 e -43.861475 -83.307203 #> 16 f 31.813325 35.649734 #> 17 g -2.887727 -63.029877 #> 18 h -77.120300 7.638770 #> 19 i -176.968946 53.419025 #> 20 j 18.278747 39.532440 #> 21 a 112.763127 41.074138 #> 22 b 51.686851 -81.393091 #> 23 c -155.137679 -8.752372 #> 24 d 82.337858 52.968592 #> 25 e 61.960031 58.432019 #> 26 f 115.128357 -52.370719 #> 27 g 149.263761 -59.722824 #> 28 h 68.389445 86.449360 #> 29 i -2.887991 18.120602 #> 30 j 52.894314 -62.698266 #> 31 a -15.654616 -37.307038 #> 32 b -134.839216 -9.349088 #> 33 c 37.571391 58.303409 #> 34 d 117.657625 84.492779 #> 35 e 42.976170 -36.826350 #> 36 f 122.779336 -48.115847 #> 37 g -26.191221 -31.413413 #> 38 h 96.943213 -71.933019 #> 39 i 76.370685 -30.559435 #> 40 j -157.187805 -55.332234 #> 41 a -26.638115 -41.602745 #> 42 b -148.220048 69.035282 #> 43 c -105.005945 30.712169 #> 44 d -97.826086 -76.622208 #> 45 e -161.840828 33.355657 #> 46 f 22.255651 18.146806 #> 47 g 69.928612 37.105286 #> 48 h -97.940644 -5.730118 #> 49 i 165.712898 -88.022172 #> 50 j -2.578611 50.993225 #> 51 a 80.355127 21.933594 #> 52 b -3.109290 65.890573 #> 53 c 124.327829 75.573421 #> 54 d -170.960521 -31.428194 #> 55 e 17.424087 74.837172 #> 56 f 163.963734 -75.501917 #> 57 g -129.419328 63.993183 #> 58 h 75.698505 -35.094784 #> 59 i -134.495320 42.545347 #> 60 j 120.836260 79.373262 #> 61 a -72.655379 64.984183 #> 62 b -42.721650 -24.449378 #> 63 c -90.774239 74.254227 #> 64 d -55.806606 45.525997 #> 65 e -28.877967 25.466834 #> 66 f 57.279595 53.181060 #> 67 g 163.424538 87.294911 #> 68 h -10.838285 22.026463 #> 69 i -125.776407 9.958768 #> 70 j 144.908225 82.991970 #> 71 a -22.310747 74.815149 #> 72 b 110.432010 18.589608 #> 73 c -6.661631 -33.920261 #> 74 d -87.106243 9.927382 #> 75 e -118.751108 78.767594 #> 76 f -122.180151 -24.293313 #> 77 g 58.100547 -29.046186 #> 78 h -11.321237 48.543041 #> 79 i 16.341423 -35.758386 #> 80 j 81.035371 23.335372 #> 81 a 9.173715 54.449951 #> 82 b 42.817120 7.602402 #> 83 c -115.574072 23.579562 #> 84 d 96.379643 -55.838003 #> 85 e 113.866188 -53.378516 #> 86 f -109.950343 77.103227 #> 87 g -103.494926 -15.580178 #> 88 h -90.421157 -66.425421 #> 89 i 89.281369 -78.990659 #> 90 j -33.392246 69.493297 #> 91 a 22.202571 16.597531 #> 92 b 90.183510 40.034193 #> 93 c 18.431196 2.230740 #> 94 d -9.594151 -36.707643 #> 95 e -157.453247 25.160052 #> 96 f -146.179423 68.857817 #> 97 g 28.865743 80.307131 #> 98 h -41.156686 37.695002 #> 99 i -94.852476 76.251704 #> 100 j 7.033548 -87.080113 #> 101 a 50.835575 -59.133908 #> 102 b 118.764086 -51.481842 #> 103 c 150.873894 62.120734 #> 104 d 154.584055 -46.202092 #> 105 e 52.312948 2.709064 #> 106 f 101.922340 65.373748
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