sylvainschmitt / SSDM

Stacked Species Distribution Modelling R package
Other
41 stars 17 forks source link

load_occ Warning: You have occurrences that aren't in the extent of your environmental variables, they will be automatically removed ! #87

Closed BettyBoyse closed 4 months ago

BettyBoyse commented 4 years ago

Dear Sylvain,

I am sorry to be such a nuissance but I am also having a problem with loading my occurrence data.

I am using this code: occurrences <- load_occ(path = "C:/Users/betty/OneDrive/Documents/Leeds/Med Meta-analysis/med.species.data.EPSG3035/all.data.year2000", Env = environmental.variables, file = "all.species.occ40.csv", sep = ",", Xcol = "coords.x1", Ycol = "coords.x2", Spcol = "scientificName", GeoRes = FALSE)

and I am receiving the warning that all my occurrences are not within the extent of my environmental variables. This results in me losing 10,000 occurrences.

However, when I run: all.env.species <- crop(all.species, extent(environmental.variables))

then I have the same number of species as when I started (as expected as my rasters and occurrences were all cropped by the same shape).

I can't understand why I am losing so many species when I use load_occ

lukasbaumbach commented 4 years ago

@BettyBoyse This sounds very much like your X and Y coordinates got mixed up. Did you try putting your longitude in Xcol and latitude in Ycol? Because in the function description Xcol is incorrectly described as latitude and Ycol as longitude, while the code uses it the other way round: https://github.com/sylvainschmitt/SSDM/blob/d8152bd234e2553d393df40fd40834e585090d20/R/load_occ.R#L83-L84

BettyBoyse commented 4 years ago

Dear Lukas,

I have double checked, my X and Y coordinates are the right way round. I ran it the other way to be sure and then I get zero occurrences.

I have just been reading in my own csv for stack_modelling instead of using load_occ to solve the problem and it seems to be working.

I have started getting this error message though: comparing variable importnace...Error in match.names(clabs, names(xi)) names do not match previous names

along with this warning: In mean.default(corr, na.rm = TRUE) : argument is not numeric or logical: returning NA. I can't understand what is causing them/or where the warning is coming from within the code. Could you possibly suggest why this is?

Best wishes, Betty

lukasbaumbach commented 4 years ago

Hi Betty,

we will have a look into this again for future updates. load_occ and load_var are intended to work on a broad range of data formats, but apparently there are still some uncovered cases/problems. For now, it's best to just load your csv directly into R.

For your other questions, please open new issues (one per topic).