ropensci / CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.
https://docs.ropensci.org/CoordinateCleaner/
79 stars 21 forks source link

`clean_coordinates` fails if `zeros_rad = 0` #67

Open AMBarbosa opened 2 years ago

AMBarbosa commented 2 years ago

Hello, clean_coordinates works OK with the defaults, but it fails if we change zeros_rad to 0, i.e. if we want to remove records only if they have exactly 0 lon / lat:

exmpl <- data.frame(species = sample(letters, size = 250, replace = TRUE),
                    decimallongitude = runif(250, min = 42, max = 51),
                    decimallatitude = runif(250, min = -26, max = -11))

test <- clean_coordinates(x = exmpl, tests = "zeros", zeros_rad = 0)

# Testing coordinate validity
# Flagged 0 records.
# Testing zero coordinates
# Error in (function (classes, fdef, mtable)  : 
#             unable to find an inherited method for function ‘over’ for signature ‘"SpatialPoints", "NULL"’

If this is purposeful or difficult to fix, at least it should be mentioned in the description of this argument in the help file, so that users are not not puzzled by the error. Or you could add a line inside the function to turn zeros_rad to a very small value if the user has set it to 0 -- something like: if (zeros_rad == 0) zeros_rad <- 0.000000000000001 Cheers!