library(tmap) tmap_mode("view") # function for flitering list based on character values include <- function (theList, toMatch){ matches <- unique (grep(paste(toMatch,collapse="|"), theList, value=TRUE)) return(matches) } # function for replacing na values with 0 removeNA = function(rast){ rast[is.na(rast)] <- 0 return(rast) } # function for extending all rasters to an equal extent extend_all =function(rasters){ extent(Reduce(extend,rasters)) } # function for adding all rasters together sum_all = function(rasters, extent){ re = lapply(rasters, function(r){extend(r, extent, value=0)}) Reduce("+",re) }
Combined all species threshold maps to display species richness.
#replaces all NA values with zeros some when added to othe raster elements are not canceled out rasterList <- lapply(X = raster_List, FUN = removeNA) # Matches the extent of all rasters and adds them together r_sum = sum_all(rasterList, extend_all(rasterList)) #Replace all zeros with NA r_sum[r_sum == 0]<-NA try(qtm(r_sum), FALSE) # check write Clause and output the file if(writeRasters==TRUE){ try(raster::writeRaster(x = r_sum, filename = paste0(outputFolder, "/richnessMap_",Sys.Date() ,".tif"), overwrite=TRUE)) }
The conservation statistic is based on all known occurrance records for the species. The other conservation metrics are based on records that contain latitude and longitude values.
The table below shows the ex situ conservation summary. SRSex is a gross comparison of germplasm (G) and reference (H) records. GRSex analyzes how comprehensively the G records cover the maxent model spatially. ERSex analyzes how well the G records cover the maxent model with regard to ecosystems covered. All of the conservation metrics are on a scale from 0-100, with 0 = poor conservation and 100 = perfectly sufficient conservation. The final ex situ conservation score is called FCSex and is a mean of the three ex situ conservation scores.
DT::datatable(exsituSummary)
Map of the potential distribution, with previous germplasm collection points surrounded by a 50 km buffer overlaid. Only germplasm points are displayed on the map.
Areas of Native Range = 0
Potential Distribution = 1
Area Where samples have been collected = 2
suppressMessages(require(rgdal)) suppressMessages(require(raster)) #importFrom("methods", "as") #importFrom("stats", "complete.cases", "filter", "median") #importFrom("utils", "data", "memory.limit", "read.csv", "write.csv") if(missing(bufferDistance)){ bufferDistance <- 50000 } # create a empty vector to hold the rastes vector = c() for(i in 1:length(sort(species_list))){ # select species G occurrences occData <- occurrenceData %>% dplyr::filter(taxon == species_list[i]) %>% dplyr::filter(type == "G")%>% dplyr::select(longitude,latitude) sp::coordinates(occData) <- ~longitude+latitude sp::proj4string(occData) <- CRS("+proj=longlat +datum=WGS84") # select raster with species name for(j in 1:length(raster_List)){ if(grepl(j, i, ignore.case = TRUE)){ sdm <- raster_List[[j]] } } # convert SDM from binary to 1-NA for mask and area sdmMask <- sdm sdmMask[sdmMask == 0] <- NA # buffer G points buffer <- geobuffer::geobuffer_pts(xy = occData, dist_m = bufferDistance, output = 'sf') # rasterizing and making it into a mask buffer_rs <- fasterize::fasterize(buffer, sdm) buffer_rs[!is.na(buffer_rs[])] <- 1 buffer_rs <- buffer_rs * sdmMask buffer_rs[is.na(buffer_rs)] <- 0 gapMap <- sdmMask - buffer_rs vector <- append(vector,gapMap) } rasterListG <- lapply(X = vector, FUN = removeNA) # Matches the extent of all rasters and adds them together g_sum = sum_all(rasterListG, extend_all(rasterList)) #Replace all zeros with NA g_sum[g_sum == 0]<-NA try(qtm(g_sum), FALSE) # check write Clause and output the file if(writeRasters==TRUE){ try(raster::writeRaster(x = g_sum, filename = paste0(outputFolder, "/exsituGapMap_",Sys.Date() ,".tif"), overwrite=TRUE)) }
The table below shows the in situ conservation summary. SRSin reports the proportion of occurrences which fall within protected areas (WDPA database 2019). GRSin analyzes how comprehensively protected areas cover the maxent model spatially. ERSin analyzes how well protected areas cover the maxent model with regard to ecosystems covered. All of the conservation metrics are on a scale from 0-100, with 0 = poor conservation and 100 = perfectly sufficient conservation. The final in situ conservation score is called FCSin and is a mean of the three in situ conservation scores.
DT::datatable(insituSummary)
Map of the potential distribution, with distribution occurring within existing protected areas (WDPA 2019) highlighted.
Areas of Native Range = 0
Potential Distribution = 1
Protected Lands within the Potential Distribution = 2
proArea <- raster(system.file("data/protectedArea/wdpa_reclass.tif", package = "gapAnalysisR")) proArea <- raster::crop(x = proArea, y= r_sum) #flip the values for 1 and NA proArea[proArea== 1] <- 2 proArea[is.na(proArea)] <- 1 proArea[proArea == 2] <- NA inGapMap <- proArea * r_sum try(qtm(inGapMap), FALSE) # check write Clause and output the file if(writeRasters==TRUE){ try(raster::writeRaster(x = inGapMap, filename = paste0(outputFolder, "/insituGapMap_",Sys.Date() ,".tif"), overwrite=TRUE)) }
This table shows the combined ex situ and in situ conservation metrics. FCSc-mean is the final combined conservation score. We categorize taxa based on the final combined scores (0-25 = high priority (HP) for further conservation work; 25-50 medium (MP); 50-75 low (LP); and 75-100 sufficiently conserved (SC)
DT::datatable(fcsSummary)
DT::datatable(eooAooSummary)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.