tag:blogger.com,1999:blog-4890093519663715581.post3306928215037330881..comments2023-10-22T08:30:53.073-07:00Comments on Species In Space: Handy little snippet of R code for thinning occurrence dataDan Warrenhttp://www.blogger.com/profile/07528161395964087899noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-4890093519663715581.post-83286308482147216462015-11-18T19:09:37.906-08:002015-11-18T19:09:37.906-08:00Hi, Dan. Thank you for your reply
sample.grid can ...Hi, Dan. Thank you for your reply<br />sample.grid can also extent to n dimension by splitting the space into cube or hyper-cube if necessary. The disadvantage are that the spatial auto-correlation within a grid is not considered, and one can not determine the number of the output samples. <br />But it is possible to use your method or similar in each grid instead of the random sampling in sample.grid. In this way, we can find a balance between the spatial autocorrelation and the computing time.<br />Anyway, this is also not my focus right now. Just keep in mind. Cheers!Anonymoushttps://www.blogger.com/profile/04696171365768823052noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-29294101410499354292015-11-18T18:04:22.013-08:002015-11-18T18:04:22.013-08:00Yeah that definitely seems like it's going to ...Yeah that definitely seems like it's going to be way faster when you've got a whole bunch of points - even though this method is miles faster than spThin, it still gets quite time-consuming when you get more than a few tens of thousands of points. One thing that this method can do that I don't think sample.grid can do (unless I misunderstand) is thin points based on distance in any number of dimensions, not just spatial. You could use this algorithm (and the earlier one you posted, I think) to thin points in environment space as well as (or instead of) geographic space.<br /><br />Anyway, I don't have time to muck about with it much at the moment, I have a class to prepare. Cheers!Dan Warrenhttps://www.blogger.com/profile/07528161395964087899noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-86939181090332068142015-11-18T17:13:39.844-08:002015-11-18T17:13:39.844-08:00Hi, Dan
I am not sure which is better. My guess is...Hi, Dan<br />I am not sure which is better. My guess is that the results may be similar. But I see the computation time of yours and their thinning algorithm are both O(N^3) algorithmic complexity, but theirs should be faster than yours.<br />https://en.wikipedia.org/wiki/Computational_complexity_theory<br />Could you tell me how much time does it take for your case? It looks like you also tried spThin and it is slower?<br />My application is addressing millions of data points. So I wrote a program much faster but not stricter:<br />Spatial points are overlayed with spatial grids with a specified cell size and then get a subset from each grid with a specified number at most. If one grid has less points than the specified number, all the points are taken. If one grid has more points than the specified number, only this number of points are taken by sample. This function can be used when there are too much point observations to be handled, especially for spatially clustered observations. <br /><br />I put it into the GSIF package.<br />http://gsif.r-forge.r-project.org/sample.grid.html<br /> <br /><br />Anonymoushttps://www.blogger.com/profile/04696171365768823052noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-39038893120667273162015-11-18T11:57:50.507-08:002015-11-18T11:57:50.507-08:00Definitely seems applicable, but I can't immed...Definitely seems applicable, but I can't immediately see what advantages it might have over this method. Do you have an idea?<br />Dan Warrenhttps://www.blogger.com/profile/07528161395964087899noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-23427575893570738442015-11-18T06:49:06.493-08:002015-11-18T06:49:06.493-08:00May be try this method in the following paper.
htt...May be try this method in the following paper.<br />http://www.sciencedirect.com/science/article/pii/0377042796000350<br />Which one is better?<br /><br />Anonymoushttps://www.blogger.com/profile/04696171365768823052noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-12064678830386333842015-11-17T18:41:53.848-08:002015-11-17T18:41:53.848-08:00Funny enough, I had thought of doing essentially t...Funny enough, I had thought of doing essentially the same thing when I was originally writing this bit of code. You could get the same results from this code just by making the stop condition a minimum distance instead of a fixed number of points. Dan Warrenhttps://www.blogger.com/profile/07528161395964087899noreply@blogger.comtag:blogger.com,1999:blog-4890093519663715581.post-54328625107728611362015-11-17T18:38:11.915-08:002015-11-17T18:38:11.915-08:00Hi Dan, I was just working on a similar problem. ...Hi Dan, I was just working on a similar problem. Though I wanted to randomly sample a set of point, enforcing a minimum distance between them. And like you, I didn't care about maximizing the number of points, I just wanted it to be random. I deviate somewhat from your method, maybe because we had different motivations for doing this. Basically I did:<br /><br />1) randomly chose one point from the original, and move it to a new set (like you)<br />2) calculate the distance between this point, and all of the rest left in the original (like you)<br />3) delete from the original those points that fall within the minimum distance of the point moved to the new set<br />4) repeat until there is nothing left in the original setAnonymoushttps://www.blogger.com/profile/00690335866156902252noreply@blogger.com