knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This vignette contains all the code behind the example in the Journal of Open Source Software paper. This can be considered a real life application initially introduced in Schmid 2019 (https://doi.org/10.1177/1059712319860842), so it contains different files in inst/workflow in the package directory and does not omit any code for data preparation, manipulation or plotting. See the package README for a minimal Quickstart guide to bleiglas instead.

code_files_full_path <- list.files(
  system.file("workflow_example", package = "bleiglas", mustWork = T),
  pattern = ".R$", full.names = T
)
code_files <- basename(code_files_full_path)
sourcecode <- lapply(code_files_full_path, function(x) { paste(readLines(x), collapse="\n") })

Running the code in this vignette requires some additional packages. You can install them with

``` {r eval=FALSE} install.packages( c("Bchron", "bleiglas", "c14bazAAR", "data.table", "dplyr", "ggplot2", "magrittr", "pbapply", "purrr", "raster", "rnaturalearth", "scatterplot3d", "sf", "tibble"), repos = c( CRAN = "https://cloud.r-project.org", ropensci = "https://ropensci.r-universe.dev" ) )

## `r code_files[1]`

This first script downloads and prepares a set of spatial data objects which will later be used for plotting. The research area for this example was arbitrarily defined as a rectangle covering the most dense data accumulations in the relevant subset of the Radon-B database.

```r

r code_files[2]

This script contains the code to filter and prepare radiocarbon dates on graves from Radon-B. For the purpose of tessellation we need the dates to be transformed to a simple table with columns for the spatiotemporal position as well as for the burial type context.


dates_prepared

load(file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "dates_prepared.RData"))
data.table::as.data.table(dates_prepared)

r code_files[3]

The script for the first plot in the JOSS paper: A simple map showing the spatial distribution of the observed dates or the graves they represent.


knitr::include_graphics(
  file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "03_map_plot.jpeg")
)

r code_files[4]

In this script the tessellation is finally performed. The output is a sf object with 2D spatial polygons for different time cuts through the 3D tessellated cube. The time slices are already cut to the boundaries of the research area and the European land outline within the latter.


vertices

load(file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "tesselation_calage_center_burial_type.RData"))
data.table::as.data.table(vertices)

polygon_edges

polygon_edges

cut_surfaces[[1]][1:3]

cut_surfaces[[1]][1:3]

r code_files[5]

This script illustrates one way to create a (printable) 3D plot of the 3D tessellation output -- so again a plot script behind the second figure in the JOSS article. The input radiocarbon dates are plotted as red dots surrounded by the edges of the 3D polygons voro++ constructs. The spatial research area becomes a spatiotemporal cube.


knitr::include_graphics(
  file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "05_3D_plot.jpeg")
)

r code_files[6]

Yet another plot script for what we call the "bleiglas" plot (Figure 3 in the JOSS article). The 2D cut polygons are projected onto a map in a diachronic plot matrix. It allows to inspect the 3D tessellation in a easily digestible way, much more human readable than the afore produced 3D plot.


knitr::include_graphics(
  file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "06_bleiglas_plot.jpeg")
)

r code_files[7]

The final script and cradle of the last JOSS figure applies the bleiglas grid prediction method to account for the temporal uncertainty of the C14 dates. The result is a plot with less aesthetic, but more scientific value, as the known input errors are indicated.


knitr::include_graphics(
  file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "07_prediction_grid_plot.jpeg")
)

prediction (first 10 rows)

load(file.path(system.file("workflow_example", package = "bleiglas", mustWork = T), "prediction_grid_example.RData"))
prediction_grid_example


nevrome/bleiglas documentation built on Sept. 19, 2021, 3:12 p.m.