knitr::opts_chunk$set(fig.width = 10, fig.height = 10, tidy = TRUE, echo = FALSE)

library(LITAP)
library(gridExtra)
library(ggplot2)

if(is.null(params$rlim)) rlim <- "none" else rlim <- params$rlim
if(is.null(params$clim)) clim <- "none" else clim <- params$clim

# Get files
files <- params$out_files

read_output <- function(files) {
   x <- NULL
   if(any(stringr::str_detect(files, ".rds"))) {
      x <- readRDS(stringr::str_subset(files, ".rds"))
   } else if (any(stringr::str_detect(files, ".csv"))) {
      x <- readr::read_csv(stringr::str_subset(files, ".csv"))
   } else if(any(stringr::str_detect(files, ".dbf"))) {
      x <- foreign::read.dbf(stringr::str_subset(files, ".dbf"))
   }
   x
}

dem <- read_output(stringr::str_subset(files, "dem_fill"))
pit <- read_output(stringr::str_subset(files, "stats_pit"))
pond <- read_output(stringr::str_subset(files, "stats_pond"))
fill <- read_output(stringr::str_subset(files, "stats_fill"))

Details

Input File:

r params$file

Parameters:

LITAP version:

r packageVersion("LITAP")

Local files output

cat(paste0("- [", basename(files), "](", files, ")\n"))

Maps

grid.arrange(flow_plot(db = dem, type = "relief") + labs(title = "relief"),
             flow_plot(db = dem, type = "elevation") + labs(title = "elevation"),
             nrow = 1)
grid.arrange(flow_plot(db = dem, type = "elevation", pits = TRUE, shed = TRUE, shed_type = "initial") + 
               labs(title = "Initial Watersheds") +
               theme(plot.margin = unit(c(0, 0, 5 ,0), "mm")),
             flow_plot(db = dem, type = "elevation", pits = TRUE, shed = TRUE, shed_type = "local") + 
               labs(title = "Local Watersheds")+
               theme(plot.margin = unit(c(0, 0, 5 ,0), "mm")),
             # flow_plot(db = dem, type = "elevation", pits = TRUE, shed = TRUE, shed_type = "pond") + 
             #   labs(title = "Pond Watersheds")+
             #   theme(plot.margin = unit(c(5, 0, 0 ,0), "mm")),
             flow_plot(db = dem, type = "elevation", pits = TRUE, shed = TRUE, shed_type = "fill") + 
               labs(title = "Fill Watersheds")+
               theme(plot.margin = unit(c(5, 0, 0 ,0), "mm")),
             ncol = 2)

Results

NOTE:

Watershed stats - Pit Table

if(!is.null(pit)) DT::datatable(pit, rownames = FALSE) else message("No pit table")

Watershed stats - Fill Table

if(!is.null(fill)) DT::datatable(fill, rownames = FALSE, filter = "none", options = list(ordering=F)) else message("No fill table")


steffilazerte/LITAP documentation built on Feb. 9, 2022, 8:11 a.m.