\begin{tikzpicture}[overlay, remember picture] \node[anchor=north west, %anchor is upper left corner of the graphic xshift=2cm, %shifting around yshift=-2cm] at (current page.north west) %left upper corner of the page {\includegraphics[width=6cm]{Sustainable Farms logo RGB.png}}; \end{tikzpicture}

knitr::opts_chunk$set(echo = FALSE, fig.align = 'center')
if (params$loadexampledata){
  knitr::opts_knit$set(root.dir = normalizePath(".."))
}
if (params$loadexampledata){
  pkgload::load_all(".")
  main_app_prep()
  load("reportdata.RData")
} 
predcontext <- predictions_morecontext(cpred$spec_prob, rpred$spec_prob, refisaverage)

# covarnicenames_tbl <- read.csv("./data/nicecovarnames.csv", header = TRUE)
covarnicenames <- covarnicenames_tbl$NiceName
names(covarnicenames) <- covarnicenames_tbl$TechName
techcovar2nicename <- function(techcovarnames){
  nicenames <- covarnicenames[techcovarnames]
  return(nicenames)
}

Welcome to a detailed report of species occupancy estimates for the Box Gum Grassy Woodland patches on your farm. We hope you enjoy it. In the first section you'll find a summary of the information you provided, and which r appname used to estimate the bird occupancy probabilities of woodlands on your farm. The second section contains estimates of expected species richness. In the third and fourth sections, the report outlines the ten most likely and ten least likely birds across your woodland patches. The report also includes information on vulnerable species that may be found in your area, and an indication of how likely they are to be found in your woodland patches. Finally, the report lists the occupancy probability, for your farm's woodland patches in spring, of every species in r appname.

now <- Sys.time()
currtime <- format(now, format = "%d %B %Y at %H:%M", tz="Australia/NSW")

This report was generated on r currtime from version r appversion of the Sustainable Farm's r appname (r appurl).

Properties of woodland areas used for estimation

The estimates of bird occupancy in this report were based on the below properties of Box Gum Grassy Woodland patches. The long term climate information was extracted for the region you selected from the \href{https://www.worldclim.org/data/bioclim.html}{WorldClim} (version 1.4) climate database. We used the centre of your region for this.

The maximum and minimum temperature, summer and winter precipitation, and precipitation seasonality of the prior 12 months had little affect on species occupancy in our fitted model, and were set to the average of our data. The average temperature of the prior 12 months was set to the long term average to make the app easier to use. The precipitation of the previous 12 months defaulted to your region's historical yearly average, but could be modified by you.

You also provided latitude and longitude, and a representative year, to enable r appname to determine woody cover within 500m and 3km. You also specified whether the area is a remnant, and the presence of Noisy Miners.

The model behind r appname has a year input that was used for statistical investigation, however this input has little influence and we set it to 2018 in r appname. The representative year used to estimate woody cover has a much stronger influence on the estimates of bird occupancy.

\begin{center}

patchprops <- t(newXocc_fromselected(cval))
makeniceprops <- function(patchprops, ...){
  patchprops[row.names(patchprops) %in% c("MaxTWarmMonth.lt", "MinTColdMonth.lt"), ] <-   # convert temperatures back to celcius
    patchprops[row.names(patchprops) %in% c("MaxTWarmMonth.lt", "MinTColdMonth.lt"), ] / 10
  # patchprops[row.names(patchprops) == "NMdetected", ] <- as.logical(patchprops[row.names(patchprops) == "NMdetected", ])
  # patchprops[row.names(patchprops) == "IsPlanting", ] <- as.logical(patchprops[row.names(patchprops) == "IsPlanting", ])
  patchprops <- patchprops[c(1:5, 9, 6:8, 10:nrow(patchprops)), , drop = FALSE] #make all long-term climate at the top

  row.names(patchprops) <- techcovar2nicename(row.names(patchprops))

  patchprops_char <- format(patchprops, drop0trailing = TRUE, trim = TRUE, ...)
  patchprops_char[row.names(patchprops) == techcovar2nicename("NMdetected"), ] <- 
    as.character(as.logical(as.numeric(patchprops_char[row.names(patchprops) == techcovar2nicename("NMdetected"), ])))
  patchprops_char[row.names(patchprops) == techcovar2nicename("IsPlanting"), ] <- 
    as.character(as.logical(as.numeric(patchprops_char[row.names(patchprops) == techcovar2nicename("IsPlanting"), ])))

# Precipitation seasonality is a percentage. The R package dismo computes biovars, it imports 'cv' from package Raster (same authors). The code for 'cv' in raster has 100 * sd(z) / mean(z).
  return(patchprops_char)
}
knitr::kable(makeniceprops(patchprops),
      format = "latex",
      booktabs = TRUE,
      row.names = TRUE,
      col.names = paste("Area", 1:ncol(patchprops)))

The region of these patches was: r cval$selected_region. \end{center}

\emph{Precipitation seasonality} is the ratio of the standard deviation of monthly precipitation over the mean monthly precipitation, expressed as a percentage.

Expected number of species

Below presents estimates of the average number of species at least one woodland area on your farm. The upper bars are estimates of the expected number of species that occupy at least one woodland area on your farm r if (refisaverage){"(Scenario 1) compared to the average woodland area in our data (Average)."}else{"under Scenario 1 or Scenario 2."}

The lower two bars are estimates for r if (refisaverage){"Scenario 1"}else{"Scenario 2"} if all the woodland areas had a minimal (2%) or a large amount (20%) of nearby woody cover.

Due to the species in r appname, these estimates should be viewed as an estimate of the average number of sedentary, common, and land-based bird species occupying the r if (nrow(cval$patchattr_tbl) > 1){"patches"} else {"patch"}. According to the statistical model behind these estimates for a single woodland area, the actual number of species could vary by 8 from the estimated average.

\begin{center}

richness_plot_pdf(cpred$species_richness)

\end{center}

The 10 most likely species on your farm

# the following already loaded inside the app - so its local directory is known
# urls <- get_birdlife_url(row.names(data$spec_prob))
# stories <- readRDS("data/birdstories.rds")
# imgfilenames <- readRDS("data/imgfilenames.rds")
topten <- order(cpred$spec_prob[, "median"], decreasing = TRUE)[1:10]
imagetexfun <- function(specinfo){
  imagetex <- paste0("\\includegraphics[width=1\\linewidth, height = 1\\linewidth, keepaspectratio]{",
               gsub("\\.[^.]*$", "", specinfo$imgfilename),
               "}",
               "\\\\ ",
               "\\textcopyright ",
               specinfo$copyrightholder)
}
buildspeclatex_imagestory <- function(specname){
  specinforow <- which(speciesinfo$species == specname)
  imagetex <- imagetexfun(speciesinfo[specinforow,])
  out <- c(
    paste0("\\subsection*{", specname, "}"),
    "\\begin{minipage}{0.3\\textwidth}",
    imagetex,
    "\\end{minipage}",
    "\\hspace{1ex}",
    "\\begin{minipage}{0.7\\textwidth}",
    gsub("http([^[:space:]]*)", "\\\\url{http\\1}", speciesinfo[specinforow, "story"]),
    "\\end{minipage}"
    )
  return(out)
}
for (specname in row.names(cpred$spec_prob)[topten]){
  cat(buildspeclatex_imagestory(specname))
}

\newpage

The 10 least likely species on your farm

Of the birds in r appname, the 10 least likely species to reside in your Box Gum Grassy Woodland patches are below.

bottomten <- order(cpred$spec_prob[, "median"], decreasing = FALSE)[1:10]
buildspeclatex_justimage <- function(specname){
  specinforow <- which(speciesinfo$species == specname)
  imagetex <- imagetexfun(speciesinfo[specinforow,])
  out <- c(
    "\\begin{minipage}[b][0.40\\textwidth][t]{0.23\\textwidth}",
    "\\begin{center}",
    # "\\\\ \\vspace*{1ex} ",
    specname,
    "\\\\ ",
    "\\scriptsize ",
    imagetex,
    "\\end{center}",
    "\\end{minipage}",
    " "
    )
  return(out)
}
cat(" \\begin{center} ")
for (specname in row.names(cpred$spec_prob)[bottomten]){
  cat(buildspeclatex_justimage(specname))
}
cat(" \\end{center} ")

\clearpage

Vulnerable species

texs <- lapply(consstatus$CommonName, function(specname){
  probs <- paste("The", specname, consstatus[specname, "statussummary"],
          onespecwords(specname, cpred$spec_prob,
                       refpredictions = rpred$spec_prob,
                       refisaverage = refisaverage))
  imagewstory <- buildspeclatex_imagestory(specname)
  return(c(imagewstory, probs, "\n"))
})
a <- lapply(texs, cat)

\clearpage

Occupancy probability of every species in r appname

Below is the estimated probability of each species in r appname occupying at least one Box Gum Grassy Woodland patch on your farm. There is a 95% chance that the \emph{true} occupancy probability is within the error bars, assuming our model is correct (the uncertainty is due to uncertainty in the parameters of the fitted model).

We computed both estimate and error bars by taking the maximum of the occupancy probability of all patches. The species are arranged by body length \href{https://www.nature.com/articles/sdata201561}{(Garnett et al. Scientific Data 2, 2015)}.

plot_allspeciesprob(cpred$spec_prob)

\clearpage r if (refisaverage){"# Occupancy probability relative to the average"}else{"# Occupancy probability relative to Scenario 1"} Below shows the ratio of species occupancy probability to the occupancy probability in r if (refisaverage){"an average woodland area."}else{"Scenario 1."} Beneath is r if (refisaverage){"the properties of the average woodland area."}else{"the Scenario 1 information."}

plot_allspeciesrel(predcontext$spec_different)

\clearpage

r paste("Attributes and species probabilities of", if (refisaverage){"the average woodland area"}else{"Scenario 1"})

\begin{center} \scriptsize

if (refisaverage){
  cat("These reference attributes were the default reference values, which were based on the average of our data. \\\\")
} else {
  refRegion <- rval$selected_region
  cat("The reference patch(es) were in the region:",
      refRegion,
      "\\\\")
}
if (refisaverage){
  refpatchprops <- makeniceprops(t(new_data_mean))
} else {
  refpatchprops <- makeniceprops(t(newXocc_fromselected(rval)))
}
knitr::kable(refpatchprops, digits = 3,
      format = "latex",
      booktabs = TRUE,
      row.names = TRUE,
      col.names = paste("Area", 1:ncol(refpatchprops)))
plot_allspeciesprob(rpred$spec_prob) +
  ggtitle("Reference Occupancy Probability")

\end{center}

\clearpage



sustainablefarms/farm_biodiversity_app documentation built on Sept. 13, 2023, 9:28 p.m.