Skip to content
Prev 28346 / 29559 Next

Count occurrences less memory expensive than superimpose function in several spatial objects

Hi Alexandre,
As far as I can tell (mostly from reading the docs...no prior experience of
using multiplicity or superimpose myself) it appears that they are just
calculating the number of unique values for a combination of x,y coordinate
pairs. So, you can do this by using the group by semantics of either
tidyverse or SQL to generate the res.xy data.frame. Below is an example of
generating res.xy alternatively using data.table (I'm not as familiar with
tidyverse):

target_sub1 <- rbindlist(lapply(target, as.data.table))
res1 <- target_sub1[, .(res=.N), by=.(x,y)]
res.xy1 = res1[target_sub1, on=c("x","y")]

all.equal(res.xy, res.xy1, check.attributes=FALSE) # should return TRUE

If you're using SQL then you just join the raw table with the grouped table
and you should get the table coordinates and occurrences. And, considering
the number of coordinates you have I recommend either data.table or SQL to
generate the final output.
HTH,
Vijay.


On Wed, Aug 19, 2020 at 4:22 PM ASANTOS via R-sig-Geo <
r-sig-geo at r-project.org> wrote: