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:
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?