Removes or flags records with equal latitude and longitude coordinates, either exact or absolute. Equal coordinates can often indicate data entry errors.

cc_equ(x, lon = "decimallongitude", lat = "decimallatitude",
  test = "absolute", 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”.

test

character string. Defines if coordinates are compared exactly (“identical”) or on the absolute scale (i.e. -1 = 1, “absolute”). Default is to “absolute”.

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

Note

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

See also

Examples

x <- data.frame(species = letters[1:10], decimallongitude = runif(100, -180, 180), decimallatitude = runif(100, -90,90)) cc_equ(x)
#> Testing equal lat/lon
#> Removed 0 records.
#> species decimallongitude decimallatitude #> 1 a -50.085470 -39.3636493 #> 2 b 54.903614 37.2503696 #> 3 c -128.318679 -10.4063544 #> 4 d 65.087502 31.9857341 #> 5 e 129.342922 36.1286974 #> 6 f 121.906796 -77.6868445 #> 7 g 137.272653 82.5306337 #> 8 h -94.428814 -45.9929662 #> 9 i 28.307104 76.7310002 #> 10 j 143.244902 0.4944738 #> 11 a -56.005549 78.3930856 #> 12 b 93.908963 -11.0160662 #> 13 c 83.197312 -26.9124234 #> 14 d 126.875656 -4.2292641 #> 15 e 171.294495 83.9087145 #> 16 f -139.302900 -36.5108531 #> 17 g 169.294421 -37.6833045 #> 18 h 53.309801 64.7500046 #> 19 i -159.813704 -55.2037200 #> 20 j -9.670646 55.6395068 #> 21 a -73.934995 -24.2124278 #> 22 b 39.707864 -44.5140624 #> 23 c -136.400803 64.0945825 #> 24 d 46.589943 -66.5956135 #> 25 e 76.303909 52.5433789 #> 26 f 40.349803 -25.9377282 #> 27 g -167.605476 83.5818908 #> 28 h 59.720683 -68.6370223 #> 29 i 55.068220 -7.5310831 #> 30 j -17.330962 4.2570786 #> 31 a 6.049477 60.6711106 #> 32 b 63.579887 -83.9692733 #> 33 c 137.135914 -82.2008809 #> 34 d 83.242496 52.5785300 #> 35 e -36.496867 -53.5141863 #> 36 f -25.012565 -77.6168193 #> 37 g -127.653355 65.5993932 #> 38 h -17.596681 -76.1238253 #> 39 i 28.361337 -12.4193847 #> 40 j -154.649837 85.2520604 #> 41 a 87.237425 12.7723219 #> 42 b 17.719454 45.7931962 #> 43 c 48.435938 -46.3582207 #> 44 d -130.813710 22.8884158 #> 45 e 154.884059 -59.6853715 #> 46 f 54.402710 -9.9378661 #> 47 g 10.335338 -60.3584579 #> 48 h -98.958460 -68.7101791 #> 49 i 173.976073 -23.8564097 #> 50 j -140.742437 80.3806029 #> 51 a -154.819614 67.5739374 #> 52 b 99.952382 -43.1893958 #> 53 c 56.996003 28.3137187 #> 54 d -86.687012 -68.0643674 #> 55 e 150.601624 -32.6073530 #> 56 f -126.464275 22.1509854 #> 57 g 50.644975 -9.5404626 #> 58 h -107.554167 37.4928203 #> 59 i 87.703673 70.2052200 #> 60 j 125.149474 -71.2248293 #> 61 a 127.308914 23.4741094 #> 62 b 109.228526 61.4806039 #> 63 c -171.404365 -24.4327623 #> 64 d 106.335977 22.1261001 #> 65 e 139.158184 -7.0654475 #> 66 f 36.013442 -60.5857897 #> 67 g -24.196260 2.4960352 #> 68 h 151.299289 -64.2120411 #> 69 i 41.765194 27.0537662 #> 70 j -23.141463 -62.0469844 #> 71 a 143.029588 1.4957752 #> 72 b 96.844868 -74.5433200 #> 73 c -133.878327 0.5447994 #> 74 d 13.907923 -83.0570610 #> 75 e -133.554159 58.3259179 #> 76 f 3.947358 -38.5225967 #> 77 g 15.765369 -45.5848439 #> 78 h -92.960608 -18.3611530 #> 79 i 109.131881 23.7767175 #> 80 j 161.248941 80.7441921 #> 81 a -33.349916 -28.7785361 #> 82 b 5.308043 22.9258774 #> 83 c 173.355066 58.4847711 #> 84 d -52.492778 -63.8792322 #> 85 e -15.897547 84.0850435 #> 86 f -100.791106 -74.5129819 #> 87 g -150.540112 -46.7169778 #> 88 h -47.075015 24.9990719 #> 89 i -134.400030 0.6111147 #> 90 j 86.354102 -44.9058133 #> 91 a 164.111863 86.2260794 #> 92 b 60.722821 28.1843248 #> 93 c -11.487834 -73.8271978 #> 94 d 13.749281 23.4977275 #> 95 e -60.856667 67.8181791 #> 96 f 46.325559 77.4506764 #> 97 g -17.081110 -14.4925465 #> 98 h 139.685464 -0.7992234 #> 99 i 102.312655 -26.5131555 #> 100 j -130.298562 -45.2277239
cc_equ(x, value = "flagged")
#> Testing equal lat/lon
#> Flagged 0 records.
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE #> [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE #> [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE #> [46] TRUE TRUE TRUE 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 TRUE TRUE TRUE #> [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE #> [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE