Percentage of overlap between polygons

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Percentage of overlap between polygons

Hi everyone,

I'm new to R and it's my first time posting here, thought to let you guys know I'm still a newbie in the R language with the hope it will simplify your answers. I'm currently doing my masters dissertation which includes a lot of work with shapefiles containing distributions of different species in South Africa. My research includes 4 families of animals; 1 prey family (consisting of 29 species) and 3 predatory families (each containing even more species). For each species I have a shapefile with a polygon of their distribution, so I have a LOT of shapefiles. My problem now is, I have to calculate the percentage of overlap each predator has with each prey species (100% overlap is when the distribution/polygon of the predator is within the distribution/polygon of the prey, so percentage should be calculated relative to the polygon of the prey species).

I know I could probably do this one by one for each species separately, but this would literally take me weeks and I don't have time for that. Even my promotor at uni hasn't done anything like this before and is trying to figure it out himself. He originally gave me this code:

my_rangemaps <- list.files(path = "imagine_rangemaps", pattern = ".shp", full.names = TRUE)
rangemap_matrix <- pairwiseRangemaps(my_rangemaps, projection = 3035, Ncpu = 1, nchunks = 1, filename = "rangemap_matrix.csv")

But the result was not what we expected as it doesn't calculate percentages relative to whatever polygon. Does anyone know a way to get percentages of overlap using a relative easy code without too much fuzz? Maybe resulting in the form of a matrix containing all species/shapefiles/polygons?

Thank you all in advance!