I would like to calculate the area of overlap between the geographical distribution of 250 prey species and 5000 potential predator species. For each species I have a shape file in .shp
format.
In the past I've used the following code for a few comparisons:
require(fuzzySim)
library(PBSmapping)
library(maptools)
rangemaps <- list.files(path = "image_rangemaps",pattern = ".shp", full.names = TRUE)
rangemap_matrix <- pairwiseRangemaps(rangemaps, projection = 3035, Ncpu = 1, filename = "rangemap_matrix.csv")
For this analysis, pairwiseRangemaps
will generate a 5250 x 5250 matrix, which is impossible for any 'decent' computer to complete in a reasonable time. Even splitting the data set in smaller sets and removing the values in the upper triangle of the matrix is not working.
The problem is that R will calculate the overlap between ALL predator pairs and ALL prey pairs as well, which is something I'm not interested in. I only would like to know the overlap between EACH prey and EACH predator.
Is there a way to do this in R? Ideally I would like a 250 x 5000 data set with the rows being the 250 prey species and the columns being the 5000 predator species.