#complete code for analysis of Functional Diversity Datset # Del Toro et. al. 2015 Diversity and Distributions #set working directory setwd ("SET YOUR WORKING DIRECTORY HERE") #load libraries library (FD) library(vegan) library (reshape) library(ggplot2) #Load datasets #format abundance data abundance<-read.csv('abundance_raw.csv',header=T) abundance2<-aggregate (cbind(ambpal,aphful,aphpic,aphrud,aphten,aphtre,bradep, camame,camcas,camchr,camher,camnea,camnov,campen,camsub,crecer,crelin,dolmar,dolpla, doltas,forarg,forase,fordif,fordol,forexc,forgla,forinc,forint,forlas,forneo1,forobs, forpal,forque,forsub1,forsub2,forsub3,lasali,lasfla,lasnea,lasneo,laspal,lasspe,lassub, lasumb,monema,monvir,myrame1,myrame2,myrdet,myrfra,myrinc,myrlob,myrpun,myrscu,nylpar, phepil,ponpen,preimp,solmol,soltex,stebre,stedie,steimp,stesch,tapses,temamb,temcur,temlon, temsch,tetcae)~Site, abundance, sum) obj<- abundance2$Site row.names(abundance2) <- obj abundance<-abundance2[,2:71] #Tree 1: 14 equally weighted traits, #format traits data traits<-read.csv('FD_traits_final.csv', header=T) obj<- traits$Species_Code row.names(traits) <- obj traits<-traits[,2:15] str(traits) ant_FG.1<- dbFD(x=traits, a=abundance, corr = "cailliez",calc.FGR = TRUE, clust.type = "ward") #tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/FG_Tree1.tif", width = 480, height = 480, units = "px", pointsize = 12, compression = "lzw", bg = "white", res = 600) #obj<- traits$Species_Code #row.names(traits) <- obj #traits<-traits[,2:15] #div=ant_FG.1$FDiv #dis=ant_FG.1$FDis #rao=ant_FG.1$RaoQ #FGR=ant_FG.1$FGR #eve=ant_FG.1$FEve #x<-cbind (eve,div,dis,rao,FGR) #write.csv(x, file="C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/Datasets/dbFD_summary_tree1.csv") ################################################################################# #SEE SUPPORTING SDM AND FGM SYNTHESIS CODE #set working directory setwd ("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/Datasets/") #We can now do simple regressions to look for relationships between diversity metrics and environmental variables. #read in data F_Div<-read.csv('Site_Summary_05_06_14.csv', header=T) str(F_Div) pairs(F_Div[2:12], pch=16) #richness vs functional diversity par(mfrow=c(1,1)) lm1<-lm ( rao~Obs_Richness, data=F_Div) summary (lm1) plot (rao~Obs_Richness, data=F_Div, pch=16, xlab="Species Richness", ylab="Rao's Q") abline(lm1, lty=3) lines (lowess (F_Div$rao~F_Div$Obs_Richness)) poly.mod<- lm (F_Div$rao ~ poly (F_Div$Obs_Richness, 2, raw=T)) summary (poly.mod) p <- data.frame(x=F_Div$Obs_Richness,y=predict(poly.mod)) p <- p[order(p$x),] lines(p, col='blue',lwd=2) #save the plot #tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/Figures/RichVsFD.tif", # width = 6, height = 6, units = "in", pointsize = 12, compression = "lzw", bg = "white", res = 600) plot (rao~Obs_Richness, data=F_Div, pch=16, xlab="Species Richness", ylab="Rao's Q") abline(lm1, lty=3) lines(p, col='blue',lwd=2) #dev.off() #Observed richness vs. Observed Functional Groups lm2<- lm (FGR ~ Obs_Richness, data=F_Div) summary (lm2) plot (FGR~Obs_Richness, data=F_Div, pch=16, xlab="Species Richness", ylab="Number of Functional Groups") abline(lm2, lty=3) lines (lowess (F_Div$FGR~F_Div$Obs_Richness)) poly.mod2<- lm (F_Div$FGR ~ poly (F_Div$Obs_Richness, 2, raw=T)) summary (poly.mod2) p <- data.frame(x=F_Div$Obs_Richness,y=predict(poly.mod2)) p <- p[order(p$x),] lines(p, col='blue',lwd=2) #save the plot #tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/Figures/RichVsFG.tif", width = 6, height = 6, units = "in", pointsize = 12, compression = "lzw", bg = "white", res = 600) plot (FGR~Obs_Richness, data=F_Div, pch=16, xlab="Species Richness", ylab="Number of Functional Groups", ylim=c(0,10)) abline(lm2, lty=3) lines(p, col='blue',lwd=2) #dev.off() #stacking SDMs and FGMs #note that file directories must be changed to wherever the user has stored the SDMs and FGMs #load required libraries require (raster) require(rgdal) #set working directory #Get border data and state data USA<-getData('GADM', country='USA', level=0) Canada<-getData('GADM', country='CAN', level=0) state <- readOGR(dsn = 'C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/shp_files/usa_state_shapefile.shp', layer = "usa_state_shapefile") projection(state) <- CRS("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs") # Subset US shapefile by desired states nestates <- c("Maine", "Vermont", "Massachusetts", "New Hampshire" ,"Connecticut", "Rhode Island","New York","Pennsylvania", "New Jersey", "Maryland", "Delaware", "Virginia", "West Virginia") state.sub <- state[as.character(state@data$STATE_NAME) %in% nestates, ] ext=extent(-85, -65, 35, 50) ########################## #Stack the SDMs to identify patterns of richness #load in all maps files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses str(files) #stack the maps SDM.Stack<-stack (files) #Stack the rasters into a single raster object str(SDM.Stack) #overlay maps, add and plot them Species.Richness.Map<-calc(SDM.Stack, sum) #sum the values Species.Richness.Map.sub<-mask (Species.Richness.Map,state.sub, col=(rgb.palette(100)), cex.axis=1.35) plot(Species.Richness.Map.sub) plot (state.sub,add=TRUE,lwd=2.0) #save the map as a tiff tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/Figures/S_SDM Richness.tif", width = 6, height = 6, units = "in", pointsize = 12, compression = "lzw", bg = "white", res = 600) plot (Species.Richness.Map.sub, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main='S_SDM Predicted Richness') plot (state.sub,add=TRUE,lwd=2.0) dev.off() #save the raster #writeRaster (x=Species.Richness.Map.sub, filename='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/S_SDM_Richness_Map.asc') ############################################## #build a functional group richness map using stacked distribution models within each group files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group1/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses str(files) group1<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group1/Group1_richness.asc") group1<-mask (group1, state.sub) group2<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group2/Group2_richness.asc") group2<-mask (group2, state.sub) group3<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group3/Group3_richness.asc") group3<-mask (group3, state.sub) group4<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group4/Group4_richness.asc") group4<-mask (group4, state.sub) group5<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group5/Group5_richness.asc") group5<-mask (group5, state.sub) group6<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group6/Group6_richness.asc") group6<-mask (group6, state.sub) group7<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group7/Group7_richness.asc") group7<-mask (group7, state.sub) group8<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group8/Group8_richness.asc") group8<-mask (group8, state.sub) group9<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group9/Group9_richness.asc") group9<-mask (group9, state.sub) group10<-raster("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group10/Group10_richness.asc") group10<-mask (group10, state.sub) #save the map as a tiff tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/Figures/S_FGM Richness_.tif", width = 8.5, height = 17, units = "in", pointsize = 12, compression = "lzw", bg = "white", res = 600) par(mfrow=c(5,2)) plot(group1, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 1") plot (state.sub,add=TRUE,lwd=1.5) plot(group2, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 2") plot (state.sub,add=TRUE,lwd=1.5) plot(group3, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 3") plot (state.sub,add=TRUE,lwd=1.5) plot(group4, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 4") plot (state.sub,add=TRUE,lwd=1.5) plot(group5, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 5") plot (state.sub,add=TRUE,lwd=1.5) plot(group6, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 6") plot (state.sub,add=TRUE,lwd=1.5) plot(group7, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 7") plot (state.sub,add=TRUE,lwd=1.5) plot(group8, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 8") plot (state.sub,add=TRUE,lwd=1.5) plot(group9, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 9") plot (state.sub,add=TRUE,lwd=1.5) plot(group10, ext=ext, col=(rgb.palette(100)), cex.axis=1.35, main="Group 10") plot (state.sub,add=TRUE,lwd=1.5) dev.off() ################################################################################# #build a loop to create the consensus maps for all of the species for future cliamte scenarios #set working directory setwd ('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/') #libraries require (raster) #load in species list species<-read.csv ('species_list.csv', header=T) species<-unique(as.character(species$Species)) str(species) #load in boundaries for plotting state <- readOGR(dsn = 'C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/shp_files/usa_state_shapefile.shp', layer = "usa_state_shapefile") projection(state) <- CRS("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs") # Subset US shapefile by desired states nestates <- c("Maine", "Vermont", "Massachusetts", "New Hampshire" ,"Connecticut", "Rhode Island","New York","Pennsylvania", "New Jersey", "Maryland", "Delaware", "Virginia", "West Virginia") state.sub <- state[as.character(state@data$STATE_NAME) %in% nestates, ] provinces<-readOGR (dsn = 'C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/shp_files/canadian_provinces.shp', layer = "canadian_provinces") projection(provinces) <- CRS("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs") canprov<- c ("Quebec", "Ontario", "Newfoundland & Labrador", "New Brunswick", "Prince Edward Island") provinces.sub <- provinces[as.character(provinces@data$NAME) %in% canprov, ] windows(width=500,height=500) plot (provinces.sub) ext=extent(-85, -65, 35, 55) ##loop starts here: for(i in 1:length(species)) { #load the outputs BRT.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/A2_2020_binary.asc')) GAM.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/A2_2020_binary.asc')) GLM.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/A2_2020_binary.asc')) MH.2020<- raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/A2_2020_binary.asc')) ME.2020<- raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/A2_2020_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2020<- overlay (BRT.2020, GAM.2020, GLM.2020,MH.2020, ME.2020,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2020, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_A2_2020_consensus.asc')) ################################################################### #load the outputs BRT.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/A2_2050_binary.asc')) GAM.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/A2_2050_binary.asc')) GLM.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/A2_2050_binary.asc')) MH.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/A2_2050_binary.asc')) ME.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/A2_2050_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2050<- overlay (BRT.2050, GAM.2050, GLM.2050,MH.2050, ME.2050,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2050, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_A2_2050_consensus.asc')) ################################################################### #load the outputs BRT.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/A2_2080_binary.asc')) GAM.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/A2_2080_binary.asc')) GLM.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/A2_2080_binary.asc')) MH.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/A2_2080_binary.asc')) ME.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/A2_2080_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2080<- overlay (BRT.2080, GAM.2080, GLM.2080,MH.2080, ME.2080,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2080, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_A2_2080_consensus.asc')) #load the outputs BRT.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/B2_2020_binary.asc')) GAM.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/B2_2020_binary.asc')) GLM.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/B2_2020_binary.asc')) MH.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/B2_2020_binary.asc')) ME.2020<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/B2_2020_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2020<- overlay (BRT.2020, GAM.2020, GLM.2020,MH.2020, ME.2020,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2020, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_B2_2020_consensus.asc')) ################################################################### #load the outputs BRT.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/B2_2050_binary.asc')) GAM.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/B2_2050_binary.asc')) GLM.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/B2_2050_binary.asc')) MH.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/B2_2050_binary.asc')) ME.2050<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/B2_2050_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2050<- overlay (BRT.2050, GAM.2050, GLM.2050,MH.2050, ME.2050,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2050, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_B2_2050_consensus.asc')) ################################################################### #load the outputs BRT.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/BRT/B2_2080_binary.asc')) GAM.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GAM/B2_2080_binary.asc')) GLM.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/GLM/B2_2080_binary.asc')) MH.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/Mahalanobis/B2_2080_binary.asc')) ME.2080<-raster(paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/All SDMs/All Outputs/', species[i],'/MaxEnt/B2_2080_binary.asc')) #create an ensamble map where 4 of 5 models agree on presence consensus_map_2080<- overlay (BRT.2080, GAM.2080, GLM.2080,MH.2080, ME.2080,fun=function(v,w,x,y,z)v+w+x+y+z>=4) #write the output asc. writeRaster(consensus_map_2080, filename=paste0('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/',species[i],'_B2_2080_consensus.asc')) } ########################################## #This loop is used to develop summary maps for each functional group showing # Current and future richness and distribtuion patterns for each functional group #set wd setwd ('C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/') #libraries require (raster) #load in boundaries for plotting state <- readOGR(dsn = 'C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/shp_files/usa_state_shapefile.shp', layer = "usa_state_shapefile") projection(state) <- CRS("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs") # Subset US shapefile by desired states nestates <- c("Maine", "Vermont", "Massachusetts", "New Hampshire" ,"Connecticut", "Rhode Island","New York","Pennsylvania", "New Jersey", "Maryland", "Delaware", "Virginia", "West Virginia") state.sub <- state[as.character(state@data$STATE_NAME) %in% nestates, ] provinces<-readOGR (dsn = 'C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/shp_files/canadian_provinces.shp', layer = "canadian_provinces") projection(provinces) <- CRS("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs") canprov<- c ("Quebec", "Ontario", "Newfoundland & Labrador", "New Brunswick", "Prince Edward Island") provinces.sub <- provinces[as.character(provinces@data$NAME) %in% canprov, ] windows(width=500,height=500) plot (provinces.sub) #designate the extent of the plots ext=extent(-85, -65, 35, 55) #baseline richness map richness.2000<- raster ("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group1/Group1 Maps and Summary/Group1_Richness.asc") PA.2000<- raster ("C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group1/Group1 Maps and Summary/Group1_PA.asc") #build the richness and P/A maps for 2020, 2050, 2080 in A2 and B2 scenarios files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/A2/2020/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2020.A2.Map<-calc(SDM.Stack, sum) PA.G1.2020.A2.Map<-(Richness.G1.2020.A2.Map>=1) files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/A2/2050/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2050.A2.Map<-calc(SDM.Stack, sum) PA.G1.2050.A2.Map<-(Richness.G1.2050.A2.Map>=1) files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/A2/2080/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2080.A2.Map<-calc(SDM.Stack, sum) PA.G1.2080.A2.Map<-(Richness.G1.2080.A2.Map>=1) files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/B2/2020/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2020.B2.Map<-calc(SDM.Stack, sum) PA.G1.2020.B2.Map<-(Richness.G1.2020.B2.Map>=1) files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/B2/2050/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2050.B2.Map<-calc(SDM.Stack, sum) PA.G1.2050.B2.Map<-(Richness.G1.2050.B2.Map>=1) files<-list.files(path='C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Future Climates/Group1/B2/2080/', pattern='asc', full.names=TRUE) #Find the files change route to change the resolution of the analyses SDM.Stack<-stack (files) Richness.G1.2080.B2.Map<-calc(SDM.Stack, sum) PA.G1.2080.B2.Map<-(Richness.G1.2080.B2.Map>=1) #create a series of summary maps tiff(filename = "C:/Users/Israel/Desktop/Chapter 3/Data and Analysis/SDMs/Group1/Group1 Maps and Summary/FG_Richness.tif", width = 8.5, height = 22, units = "in", pointsize = 12, compression = "lzw", bg = "white", res = 600) par(mfrow=c(7,2)) plot (richness.2000, main="Current Richness") plot (PA.2000,main="Current P/A") plot(Richness.G1.2020.A2.Map, main="A2-2020") plot(PA.G1.2020.A2.Map,main="A2-2020") plot (Richness.G1.2050.A2.Map, main="A2-2050") plot (PA.G1.2050.A2.Map,main="A2-2050") plot (Richness.G1.2080.A2.Map, main="A2-2080") plot (PA.G1.2080.A2.Map, main="A2-2080") plot (Richness.G1.2020.B2.Map,main="B2-2020") plot (PA.G1.2020.B2.Map,main="B2-2020") plot (Richness.G1.2050.B2.Map,main="B2-2050") plot (PA.G1.2050.B2.Map,main="B2-2050") plot (Richness.G1.2080.B2.Map, main="B2-2080") plot (PA.G1.2080.B2.Map ,main="B2-2080")