Working in R, I have a grid map of the world (as SpatialPolygonsDataFrame object). I have also many indipendent shapefiles (formed by several polygons) expressing species ranges. I grouped all these shapefiles representing distributions in a single list.
species <- list(sp1, sp2, sp3, sp4, sp5)
What I want to obtain as output is a dataframe where for each cell of my grid (put in the rows of the dataframe) I have in the columns the presence/absence (expressed by the values 1 and 0, respectively) of all species of my list. See the example I want to obtain:
Best Answer
The steps to achieve what you want could be:
I'm using
sf
package to manage spatial objects,rworldmap
to get example data andmapview
to make interactive map plots.Note: I'm simulating the species home range polygons as countries boundaries
Check the commented code below.