JamesDMSpeed / PhyloTroph

Phylogenetic diversity across trophic levels
0 stars 0 forks source link

SR map #6

Open kjerstrs opened 4 years ago

kjerstrs commented 4 years ago

It has taken a long time to figure out the SR map, but after trying different methods and adjustments I think I now have managed to make a richness map by stacking all the layers together in a rasterstack. I've uploaded the script to Github, but I'm not sure if the map works ideally yet. Since the shapefiles won't read through github, I've upoloaded a folder (Birds_fix) which contains an altered shapefile for birds, which was necessary to fix the corrupt polygon. I also struggle to figure out how to assess which species are found within each grid cell. I understand that getValues will give the total number of species, but I would like to know which species 'make up' that cell value. ` @JamesDMSpeed @damarismm

JamesDMSpeed commented 4 years ago

You can use the extract function to get all the layers out - set df=T which will convert it to a dataframe along with a cell ID column. Each column will then be a species, and each row a cell.

kjerstrs commented 4 years ago

In order to stack the SR layers together, I adjusted the different dimensions to a certain value so they all could be set to the same extent without loss of any values (81, 55).The problem is that since I have changed the dimensions, the cells within each layer is no longer 'aligned'. When extracting cell values from the rasterBrick, the summed up cell values gets wrong. As an example, according to the richness map for mammals, there supposed to be 19 species within cell 48, but in the raster stack where the different feeding groups (herbivores, carnivores etc. ) are stacked, the mammals sum up to 15, because the carnivore mammals are not aligned with the other mammal layers, i.e missing 4 species. Is there somehow to stack the layers, and still make sure that they'll align when extracting their cell values? I've tried resampling, without luck, and tried to only change the extent, and not the dimensions, but then some values are lost by getting 'cropped out'. @JamesDMSpeed @damarismm

JamesDMSpeed commented 4 years ago

The issue is that you have rasterized the distribution maps (and hence species richness maps) with different raster grids. I have pushed an edit with the mammal data, rasterizing to the plant richness grid. You can repeat this change for the other taxa, and then all the species richness maps will be stackable.

kjerstrs commented 4 years ago

I mentioned in the meeting on Tuesday that that the mammal richness is separated into two groups according to the SR maps, with SR ranging from 1-8 and from 16-39. I looked more closely into it in ArcGis and found that the cells with 1-8 species are all located along the coast, caused by some rodent species which have a distribution covering the islets/islands along the coast of Norway. Is this a reasonable explanation of the gap in SR (that a small number of different mammal species within a cell are only found on these islands, otherwise its at least 16 different species) or is it more likely to be caused by some errors with the shapefile or the coding of the map itself? I've looked into the coding of richnessMap_mam, but couldn't find any obvious errors. @JamesDMSpeed @damarismm

JamesDMSpeed commented 4 years ago

That sounds like a reasonable explanation Kjersti. You could consider whether to drop cells with e.g. <50% land cover in them. But that can be done at a later stage if you decide for that.

kjerstrs commented 4 years ago

I've now made a table (tableOfSpecies) which contains all of the species names(ex. plants) and which raster stack cells they're found in, their taxonomic group, and their trophic group. So I guess the next step would be to get the phylogenies from Timetree and read that into R in order to start calculationg PD's? @JamesDMSpeed @damarismm

JamesDMSpeed commented 4 years ago

Yes You can decide whether to make the species richness maps in the different taxonomic/trophic groups first, or do get the phylogeny first. For the phylogeny you need to save the species names as a .txt file (one species per line). Import to timetree and download the .nwk file.