LimaRAF / plantR

An R Package for Managing Species Records from Biological Collections
GNU General Public License v3.0
18 stars 4 forks source link

validateCoord() #73

Closed leilameyer08 closed 3 years ago

leilameyer08 commented 3 years ago

Hi! I installed the latest version of plantR today and now the validateCoord() function is no longer working for my dataset.

Code: occs.all.6 <- read.csv("output.occs.all.6.csv", encoding = "native.enc") occs.all.7 <- validateCoord(occs.all.6, output = "new.col")

Error in s2_geography_from_wkb(x, oriented = oriented, check = check) : Evaluation error: Found 1 feature with invalid spherical geometry. [194] Loop 2 edge 8 crosses loop 3 edge 0.

The dataset is available at: https://github.com/leilameyer08/plantR/blob/main/output.occs.all.6.csv

Thank you!

LimaRAF commented 3 years ago

Dear @leilameyer08,

Thanks for the issue and the test dataset. We will look into it asap.

It seems that the sf package has changed the way they handle spherical geometries.

We will get back to you on this soon.

AndreaSanchezTapia commented 3 years ago

I'm checking this and getting:

Error in checkOut(x5, lon = ifelse(output == "same.col", lon, paste0(lon,  : 
  Coordinate column names do not match those of the input object: please rename or specify the correct names
Called from: checkOut(x5, lon = ifelse(output == "same.col", lon, paste0(lon, 
    ".new")), lat = ifelse(output == "same.col", lat, paste0(lat, 
    ".new")), tax.name = tax.name, geo.name = ifelse(output == 
    "same.col", "geo.check", "geo.check.new"), cult.name = "cult.check", 
    clas.cut = 3, rob.cut = 16)

I'll keep you posted.

saramortara commented 3 years ago

with the latest sf package I'm getting this error in the vignette:

Quitting from lines 264-265 (plantr_introduction.Rmd) Error: processing vignette 'plantr_introduction.Rmd' failed with diagnostics: st_crs(x) == st_crs(y) is not TRUE

LimaRAF commented 3 years ago

Dear @leilameyer08 (cc @AndreaSanchezTapia @saramortara),

We just went through the example and the code of the function. The first error you were getting was related to a difference in the projections across the plantR internal maps, which were already solved.

Then we realize that @leilameyer08 data went to an excection we have not antecipated, due to a combination of no inverted or transposed coordinates in the data and the argumento output set to 'new.col'. In this case, the data frame missed the second checkCoord() step and the new columns '"decimalLongitude.new.new"' and "decimalLatitude.new.new" were not added to the dataset. These led to the error @AndreaSanchezTapia mentioned. I added an alternative to create the new columns despite of the presence of coordinates flagged as inverted or transposed in the data, and the error was not there and I am not getting the vignette error @saramortara mentioned. Note that with this solution "decimalLatitude.new" and "decimalLatitude.new.new" are actually the same.

Well, hopefully everything should be ok. Modifications are right now at the plantR 'dev' branch but they should be merged with the master branch real soon.

Please let us know if you still runs into trouble.