Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean_coordinates() occasional error with outliers test #91

Closed
AMBarbosa opened this issue Oct 9, 2023 · 3 comments
Closed

clean_coordinates() occasional error with outliers test #91

AMBarbosa opened this issue Oct 9, 2023 · 3 comments

Comments

@AMBarbosa
Copy link
Contributor

With some datasets, I'm getting an error when using the outliers test. Here's an example where this happens:

dat <- read.csv("https://raw.githubusercontent.com/AMBarbosa/files/main/elephant.csv")

dat_cc <- clean_coordinates(dat, lon = "decimalLongitude", lat = "decimalLatitude", 
          species = "species", tests = "outliers")

# Testing coordinate validity
# Flagged 0 records.
# Testing geographic outliers
# Error in h(simpleError(msg, call)) : 
#   error in evaluating the argument 'x' in selecting a method for function 'ext': [vect] the variable name(s) in argument `geom` are not in `x`
# In addition: Warning message:
#   In cc_outl(otl_test, lon = lon, lat = lat, species = species, method = outliers_method,  :
#                Using raster approximation.

packageVersion("CoordinateCleaner")
# [1] ‘3.0’
@mhesselbarth
Copy link
Contributor

I am running in the same issues. My first guess is that this is based on ras_create(), and more specifically the terra::vect() function. Currently the function doesn't consider the name of the lon/lat col names.

ex <- terra::ext(terra::vect(x[, c(lon, lat)], geom=c(lon, lat))) + thinning_res * 2

Also, I think the new name of terra objects is lyr.1 and not layer

I think my PR #92 might fix all this, but please double check :)

@AMBarbosa
Copy link
Contributor Author

The terra::vect() function takes "lon" and "lat" as the default coordinate column names; but in CoordinateCleaner::cc_outl(), the default values for lon and lat are "decimalLongitude" and "decimalLatitude" respectively, so they do need to be specified to terra::vect(). @mhesselbarth's PR should fix it. I'm just a bit puzzled as to why the error doesn't occur with all datasets that have outliers.

@mhesselbarth
Copy link
Contributor

I think the issue only occurs if a raster is used to detect outliers, which is not the case for all species? But I haven't looked into that too much.

BrunoVilela added a commit that referenced this issue Oct 23, 2023
joelnitta pushed a commit to joelnitta/CoordinateCleaner that referenced this issue Dec 26, 2023
joelnitta pushed a commit to joelnitta/CoordinateCleaner that referenced this issue Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants