Biogeography (Lab3)

Biogeography of the Philippine Islands

John Humphreys email: jmh09r@my.fsu.edu

date()
## [1] "Wed Nov 02 22:19:01 2016"

Options

library(knitr)
opts_knit$set(verbose = FALSE)

Load Packages:

suppressMessages(library(dplyr))
suppressMessages(library(rgdal))
suppressMessages(library(raster))

Set Directory

setwd("~/FSU/BioGeo/Lab3/Connect")

Import Data

Import and then transpose the data so that Island names are used as row names instead of column names.

PhilMam.df = read.csv("./PhilMam.csv", header = TRUE, sep=",")

PhilIsla.df = PhilMam.df[1:82,4:22]

Similarity Indicies

Calculating Simpson and Jacard similarity indices.

Simpson.df = data.frame(matrix(NA, nrow = 19, ncol = 19))
colnames(Simpson.df) = colnames(PhilIsla.df)
rownames(Simpson.df) = colnames(PhilIsla.df)

Jacard.df = Simpson.df

for (i in 1:dim(PhilIsla.df)[2]){
  
  MainName = colnames(PhilIsla.df)[i] #Name of 1st Island
  Main = PhilIsla.df[,i]              #Data for 1st Island
  
        for (j in 1:dim(PhilIsla.df)[2]){
                
            CompName = colnames(PhilIsla.df)[j] #Name of 2nd Island
            Comp = PhilIsla.df[,j]              #Data for 2nd Island
  
            RowBnd = as.data.frame(cbind(Main, Comp))
            
            RowBnd = RowBnd %>%
                     mutate(Sum = as.factor(Main + Comp))
            
            A = length(which(RowBnd$Sum == 0)) #Absent from both
            N1 = sum(RowBnd$Main)              #Total on 1st Island
            N2 = sum(RowBnd$Comp)              #Total on 2nd Island
            C = length(which(RowBnd$Sum == 2)) #Present on both
  
          Simpson = C/N1
          Jacard = C/(N1 + N2 - C)

          Simpson.df[j,i] = Simpson
          Jacard.df[j,i] = Jacard
              
          next
        }
}


#write.csv(Simpson.df, "Simpson") #Exporting as CSV
#write.csv(Jacard.df, "Jacard")

Simpson Index

kable(Simpson.df, digits = 2, align = c(rep("c", 19)))
Sunda Borneo Balabac Basilan Bohol Calamianes Camiguin Cebu Dinagat Leyte N.Luzon S.Luzon Mindanao Mindoro Negros Palawan Panay Samar Sibuyan
Sunda 1.00 0.89 0.29 0.23 0.19 0.35 0.25 0.57 0.00 0.13 0.12 0.16 0.10 0.16 0.36 0.32 0.31 0.17 0.4
Borneo 1.00 1.00 0.29 0.23 0.19 0.40 0.25 0.57 0.00 0.13 0.12 0.16 0.10 0.16 0.36 0.36 0.31 0.17 0.4
Balabac 0.50 0.44 1.00 0.46 0.38 0.50 0.38 0.71 0.00 0.30 0.24 0.32 0.23 0.26 0.45 0.48 0.38 0.39 0.4
Basilan 0.38 0.33 0.43 1.00 0.75 0.35 0.50 0.86 0.33 0.57 0.32 0.42 0.43 0.42 0.55 0.28 0.54 0.72 0.6
Bohol 0.38 0.33 0.43 0.92 1.00 0.30 0.62 0.86 0.50 0.70 0.40 0.53 0.53 0.42 0.55 0.24 0.54 0.83 0.6
Calamianes 0.88 0.89 0.71 0.54 0.38 1.00 0.25 1.00 0.00 0.30 0.24 0.32 0.23 0.32 0.64 0.72 0.54 0.39 0.4
Camiguin 0.25 0.22 0.21 0.31 0.31 0.10 1.00 0.29 0.25 0.30 0.24 0.26 0.23 0.21 0.27 0.08 0.31 0.33 0.8
Cebu 0.50 0.44 0.36 0.46 0.38 0.35 0.25 1.00 0.00 0.26 0.24 0.32 0.20 0.32 0.64 0.28 0.54 0.33 0.4
Dinagat 0.00 0.00 0.00 0.31 0.38 0.00 0.38 0.00 1.00 0.35 0.12 0.16 0.37 0.11 0.09 0.00 0.15 0.39 0.4
Leyte 0.38 0.33 0.50 1.00 1.00 0.35 0.88 0.86 0.67 1.00 0.52 0.63 0.70 0.47 0.64 0.28 0.62 1.00 0.8
N.Luzon 0.38 0.33 0.43 0.62 0.62 0.30 0.75 0.86 0.25 0.57 1.00 1.00 0.43 0.68 0.64 0.24 0.62 0.61 0.8
S.Luzon 0.38 0.33 0.43 0.62 0.62 0.30 0.62 0.86 0.25 0.52 0.76 1.00 0.40 0.63 0.64 0.24 0.62 0.61 0.8
Mindanao 0.38 0.33 0.50 1.00 1.00 0.35 0.88 0.86 0.92 0.91 0.52 0.63 1.00 0.47 0.64 0.28 0.62 0.94 0.8
Mindoro 0.38 0.33 0.36 0.62 0.50 0.30 0.50 0.86 0.17 0.39 0.52 0.63 0.30 1.00 0.64 0.24 0.62 0.50 1.0
Negros 0.50 0.44 0.36 0.46 0.38 0.35 0.38 1.00 0.08 0.30 0.28 0.37 0.23 0.37 1.00 0.28 0.85 0.39 0.6
Palawan 1.00 1.00 0.86 0.54 0.38 0.90 0.25 1.00 0.00 0.30 0.24 0.32 0.23 0.32 0.64 1.00 0.54 0.39 0.4
Panay 0.50 0.44 0.36 0.54 0.44 0.35 0.50 1.00 0.17 0.35 0.32 0.42 0.27 0.42 1.00 0.28 1.00 0.44 0.8
Samar 0.38 0.33 0.50 1.00 0.94 0.35 0.75 0.86 0.58 0.78 0.44 0.58 0.57 0.47 0.64 0.28 0.62 1.00 0.8
Sibuyan 0.25 0.22 0.14 0.23 0.19 0.10 0.50 0.29 0.17 0.17 0.16 0.21 0.13 0.26 0.27 0.08 0.31 0.22 1.0

Jacard Index

kable(Jacard.df, digits = 2, align = c(rep("c", 19)))
Sunda Borneo Balabac Basilan Bohol Calamianes Camiguin Cebu Dinagat Leyte N.Luzon S.Luzon Mindanao Mindoro Negros Palawan Panay Samar Sibuyan
Sunda 1.00 0.89 0.22 0.17 0.14 0.33 0.14 0.36 0.00 0.11 0.10 0.12 0.09 0.12 0.27 0.32 0.24 0.13 0.18
Borneo 0.89 1.00 0.21 0.16 0.14 0.38 0.13 0.33 0.00 0.10 0.10 0.12 0.08 0.12 0.25 0.36 0.22 0.12 0.17
Balabac 0.22 0.21 1.00 0.29 0.25 0.42 0.16 0.31 0.00 0.23 0.18 0.22 0.19 0.18 0.25 0.44 0.23 0.28 0.12
Basilan 0.17 0.16 0.29 1.00 0.71 0.27 0.24 0.43 0.19 0.57 0.27 0.33 0.43 0.33 0.33 0.23 0.37 0.72 0.20
Bohol 0.14 0.14 0.25 0.71 1.00 0.20 0.26 0.35 0.27 0.70 0.32 0.40 0.53 0.30 0.29 0.17 0.32 0.79 0.17
Calamianes 0.33 0.38 0.42 0.27 0.20 1.00 0.08 0.35 0.00 0.19 0.15 0.18 0.16 0.18 0.29 0.67 0.27 0.23 0.09
Camiguin 0.14 0.13 0.16 0.24 0.26 0.08 1.00 0.15 0.18 0.29 0.22 0.23 0.23 0.17 0.19 0.06 0.24 0.30 0.44
Cebu 0.36 0.33 0.31 0.43 0.35 0.35 0.15 1.00 0.00 0.25 0.23 0.30 0.19 0.30 0.64 0.28 0.54 0.32 0.20
Dinagat 0.00 0.00 0.00 0.19 0.27 0.00 0.18 0.00 1.00 0.30 0.09 0.11 0.35 0.07 0.05 0.00 0.09 0.30 0.13
Leyte 0.11 0.10 0.23 0.57 0.70 0.19 0.29 0.25 0.30 1.00 0.37 0.40 0.66 0.27 0.26 0.17 0.29 0.78 0.17
N.Luzon 0.10 0.10 0.18 0.27 0.32 0.15 0.22 0.23 0.09 0.37 1.00 0.76 0.31 0.42 0.24 0.14 0.27 0.34 0.15
S.Luzon 0.12 0.12 0.22 0.33 0.40 0.18 0.23 0.30 0.11 0.40 0.76 1.00 0.32 0.46 0.30 0.16 0.33 0.42 0.20
Mindanao 0.09 0.08 0.19 0.43 0.53 0.16 0.23 0.19 0.35 0.66 0.31 0.32 1.00 0.22 0.21 0.15 0.23 0.55 0.13
Mindoro 0.12 0.12 0.18 0.33 0.30 0.18 0.17 0.30 0.07 0.27 0.42 0.46 0.22 1.00 0.30 0.16 0.33 0.32 0.26
Negros 0.27 0.25 0.25 0.33 0.29 0.29 0.19 0.64 0.05 0.26 0.24 0.30 0.21 0.30 1.00 0.24 0.85 0.32 0.23
Palawan 0.32 0.36 0.44 0.23 0.17 0.67 0.06 0.28 0.00 0.17 0.14 0.16 0.15 0.16 0.24 1.00 0.23 0.19 0.07
Panay 0.24 0.22 0.23 0.37 0.32 0.27 0.24 0.54 0.09 0.29 0.27 0.33 0.23 0.33 0.85 0.23 1.00 0.35 0.29
Samar 0.13 0.12 0.28 0.72 0.79 0.23 0.30 0.32 0.30 0.78 0.34 0.42 0.55 0.32 0.32 0.19 0.35 1.00 0.21
Sibuyan 0.18 0.17 0.12 0.20 0.17 0.09 0.44 0.20 0.13 0.17 0.15 0.20 0.13 0.26 0.23 0.07 0.29 0.21 1.00

Download Domain Boundary:

Domain = readOGR(dsn = "./Domain", 
              layer = "Domain", 
              stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile 
## Source: "./Domain", layer: "Domain"
## with 1 features
## It has 1 fields
Islands = readOGR(dsn = "./Island", 
              layer = "Islands", 
              stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile 
## Source: "./Island", layer: "Islands"
## with 18 features
## It has 96 fields

Get Elevation and Bathymetry Data

British Oceanographic Data Center http://www.bodc.ac.uk/

DEM = raster("./Relief.tif")
plot(DEM)

Species Richness by Island

Isla.r = rasterize(Islands,
                   DEM,
                   na.rm = FALSE,
                   field = 'attrtab_TR')

Isla.r[is.na(Isla.r)] = 0

plot(Isla.r, main = "Total Species Richness")

Similarity to Sunda Shelf

Simpson Index

Islands@data = arrange(Islands@data, Set6_NAME_)

Simp2 = Simpson.df %>%
          mutate(Isla = rownames(Simpson.df))


Simp2$Isla[Simp2$Isla == "N.Luzon"] = "North Luzon"
Simp2$Isla[Simp2$Isla == "S.Luzon"] = "South Luzon"

Simp2 = arrange(Simp2, Isla) %>%
            filter(Isla != "Sunda")

Islands$SimIndx = Simp2$Sunda

Isla.r = rasterize(Islands,
                   DEM,
                   na.rm = FALSE,
                   field = 'SimIndx')

Isla.r[is.na(Isla.r)] = 0

plot(Isla.r, 
     main = "Similarity to Sunda Shelf   \n(Simpson Index)")

Study.r = round(100*Isla.r)

Jacard Index

plot.new()
Islands@data = arrange(Islands@data, Set6_NAME_)

Jac2 = Jacard.df %>%
          mutate(Isla = rownames(Simpson.df))


Jac2$Isla[Jac2$Isla == "N.Luzon"] = "North Luzon"
Jac2$Isla[Jac2$Isla == "S.Luzon"] = "South Luzon"

Jac2 = arrange(Jac2, Isla) %>%
            filter(Isla != "Sunda")

Islands$JacIndx = Jac2$Sunda

Isla.r = rasterize(Islands,
                   DEM,
                   na.rm = FALSE,
                   field = 'JacIndx')

Isla.r[is.na(Isla.r)] = 0

plot(Isla.r, 
     main = "Similarity to Sunda Shelf   \n(Jacard Index)")