-
Notifications
You must be signed in to change notification settings - Fork 3
/
species_report.Rmd
145 lines (118 loc) · 4.03 KB
/
species_report.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "species_report"
output: html_document
params:
nspeciestable: NA
speciesdata: NA
speciesrast: NA
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, echo=FALSE}
# Load the required libraries
library(ggplot2)
library(gtable)
library(grid)
library(leaflet)
library(sp)
library(rgdal)
library(raster)
library(RColorBrewer)
library(plotly)
library(dplyr)
```
## What is this document?
This markdown document was produced from the Shark Explorer App (SEA), which is currently hosted at <http://rossdwyer.shinyapps.io/sharkray_mpa/>.
This report presents data for the species...
```{r, echo=FALSE}
# Sort out the species data table
sharkdat2 <- params$speciesdata # The `params` object available in the document.
#names(sharkdat)[1] <- 'binomial' # Ensures continuity between pages
sharkdat2 <- sharkdat2 %>%
select(FBname,order_name,family_nam,
binomial,Length,
DemersPelag,Vulnerability,Resilience,
code)
levels(sharkdat2$Resilience) <- c("Very low", "Low", "Medium", "High")
sharkdat2$FBname[params$nspeciestable]
####
specName <- as.character(params$speciesdata$binomial[params$nspeciestable]) # Assign the row number to the df to extract the species name
specName
```
Which has the following attributes
```{r, echo=FALSE}
sharkdat2[params$nspeciestable,]
```
An interactive map showing the species distribution
```{r, echo=FALSE, message=FALSE, warning=FALSE}
pal <- c("#de2d26","#f93")
# Assign the species raster
newdata <- params$speciesrast
newdata[newdata <= 0] <- NA
leaflet() %>%
setView(lng = 0, lat = 0, zoom = 1) %>%
addProviderTiles(providers$OpenStreetMap.BlackAndWhite) %>%
addLegend(colors = pal[1], # Adds new legend with species name (binomial)
position = "topright",
labels = specName) %>%
addRasterImage(layerId ="layer2",
newdata,
colors=pal[1],
opacity = 0.5) %>%
mapOptions(zoomToLimits = "first")
```
The Vulnerability plot
```{r, echo=FALSE}
par(mar = c(4, 4, 1, .1), font.axis = 2,font.lab = 2) # stops the arial font issue
ggplot(data = params$speciesdata,
aes(x = code, y = Vulnerability,
fill = pointborder,colour = pointborder
)) +
geom_dotplot(dotsize = 0.4,binwidth = 2,
binaxis = "y", stackdir = "center", binpositions="all") +
scale_fill_manual(values=c("#d3d3d3"))+
scale_color_manual(values=c("#d3d3d3"))+
scale_x_discrete(limits=c("CR", "EN", "VU", "NT", "LC", "DD"))+
labs(title="",x="IUCN code", y = "Vulnerability Index")+
theme_minimal()+
theme(legend.position="none") # Remove legend
```
The dispersal data plot is shown in the box below.
```{r, echo=FALSE}
#Read in Dispersal distance data
# Df <- read.csv("Data/DispersalKernel_Properties.csv")
# # Add a column detailing if we have Dispersal distance data for a species
# sharkdat$DispersalKernel <- "No"
# for (i in 1:nrow(Df)){
# inum <- which(as.character(sharkdat$binomial)==as.character(Df$ScientificName[i]))
# sharkdat$DispersalKernel[inum] <- "Yes"
# }
#
# Function to make the empty dispersal plot
makeDispersalplot <- function(xmax=1000){
xx <- seq(0, log(xmax), length=1000)
yy <- rep(0,length(xx))
#par(oma = c(0.1,1,2,1.5))
par(mar = c(4, 4, 2, .5), font.axis = 2,font.lab = 2) # stops the arial font issue
plot(x=xx,y=yy, xaxt="n", las=1,
xlab="Maximum dispersal distance (km)",
ylab="Probability of dispersal", type="n",ylim=c(0,1),
bty="l")
axis(1, at= log(c(0.01, seq(0.1,1,l=10),
seq(1,10,l=10),seq(10,100,l=10),
seq(100,1000,l=10),
seq(1000,10000,l=10))+1), labels=F, tcl=-0.3)
axis(1, at= log(c(0.1,1,10,100,1000,10000)+1),
labels=c(0.1,1,10,100,1000,10000))
legend("top",bty="n",
inset = c(0,-0.13),
xpd = TRUE, horiz = TRUE,
lty=1,lwd=2,
col=c(1:3),
legend = c("Mark-recapture",
"Passive acoustic",
"Satellite"))
}
makeDispersalplot(1500)
```