-
Notifications
You must be signed in to change notification settings - Fork 7
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
Error in .subset2(x, i, exact = exact) : attempt to select less than one element in get1index #27
Comments
Hi @kellyecoles - are you sure the coordinates are in decimal degrees? That's a common problem that crops up. Also, if all the points are within 0.2 km of each other, then you might also get this error. |
HI @kellyecoles and @mlammens - I have had exactly this problem tonight. I successfully used that code yesterday and tonight I am getting the above error. I have two data sets for two different projects. Yesterdays data set would not work tonight even though it worked yesterday. My coordinates are in decimal degrees. I would still love to solve this problem. |
That's pretty strange @RuthPalsson . I don't suppose you could share the points, or a subset of them, so I can trouble shoot the problem? |
Thanks for your reply @mlammens My code: |
@mlammens, this is working perfectly this morning!! Who knows what was going on!! |
Odd. Usually I've seen that error when the points are too close to each other (relative to the thin distance), but that does not appear to be the case here. It is a random algorithm, so I suppose it's not totally impossible for it to work sometimes but not others. I'll have to tweak this going forward. |
@mlammens, the data I sent you had worked initially but then didn't. I had two other sets of data that I knew had locs closer than 0.2 km - I had thinned them manually in QGIS and then yesterday, I got spThin to thin both of them to <1 km apart. |
Hii, I am trying to work with a certain species for spatial thinning and am stuck with the same error. My CSV file has a species column, lat and long columns with values in decimal. head(hyp)
Beginning Spatial Thinning. Would be of great help if anyone could help me out on this. Thanks in advance! |
@riyapakhre , I think this error might be from the labels your using for the Latitude / Longitude columns in the data set being different from the names you are using in the |
I am working with a dataset of occurrence locations for an endangered species, so I am not able to share data.
I have an excel file with three columns: species, longitude and latitude.
I am working with that in R, and trying to thin the >400 points, because many of them are repeats (individuals within just one population). I have used spThin successfully in the past but am unable to get it to work now. My code is:
#Reading in Occurrences
occs <- read.xlsx("Bapmeg/BAPMEG_FL.xlsx", sheetIndex = 1)
#Thinning Occurrence Points
thin(loc.data = occs,
lat.col = "latitude", long.col = "longitude",
spec.col = "name",
thin.par = 0.2, reps = 100,
locs.thinned.list.return = TRUE,
write.files = TRUE,
max.files = 1,
out.dir = "Bapmeg/", out.base = "Bapmeg_Thin",
write.log.file = TRUE,
log.file = "BapMegThin.txt")
However, I keep getting the same error: Error in .subset2(x, i, exact = exact) :
attempt to select less than one element in get1index
I can't figure out why. I saw another thread where someone added a species column, and the code worked, but I already have a species column. Is there a minimum number of occurrences necessary? This is an extremely rare species, with probably less than 12 occurrences in the area in question.
Thanks! And if I have failed to include information, I apologize. I am very new to all this.
The text was updated successfully, but these errors were encountered: