# loganhysen/timescapes architecture

> Architecture diagram of the GitHub repository loganhysen/timescapes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/loganhysen/timescapes
- Repository: https://github.com/loganhysen/timescapes

## Overview

timescape is an R package for computing temporal landscape metrics from binary time series and raster time stacks. Its main workflow accepts a time series, dispatches a requested metric, and returns a metric value; for raster input, it applies a metric through time for each cell and can first convert categorical classes to binary presence/absence. The README also documents benchmark and plotting capabilities. No source excerpts were provided, so the graph uses only README-documented relationships and does not infer internal calls or registry behavior.

Main entry points: [`R/registry.R`](https://github.com/loganhysen/timescapes/blob/main/R/registry.R) (Metric interface), [`R/raster_metric.R`](https://github.com/loganhysen/timescapes/blob/main/R/raster_metric.R) (Per-cell metric), [`R/metrics_basic.R`](https://github.com/loganhysen/timescapes/blob/main/R/metrics_basic.R) (Basic metrics), [`R/metrics_structure.R`](https://github.com/loganhysen/timescapes/blob/main/R/metrics_structure.R) (Structure metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and raster workflow"]
  node_series["Binary time series"]
  node_raster["Raster time stack"]
  node_classify["Class to presence<br/>[raster_metric.R]"]
  node_raster_apply["Per-cell metric<br/>[raster_metric.R]"]
end

subgraph group_metrics["Temporal metrics"]
  node_metric_api["Metric interface<br/>[registry.R]"]
  node_basic_metrics["Basic metrics<br/>[metrics_basic.R]"]
  node_structure_metrics["Structure metrics"]
end

subgraph group_benchmark["Benchmarking"]
  node_benchmark["Benchmarking<br/>[benchmark_data.R]"]
  node_benchmark_plot["Benchmark plotting<br/>[plot_benchmark.R]"]
  node_run_utils["Benchmark utilities<br/>[utils.runs.R]"]
end

node_user(("Package user"))

node_user -->|"provides"| node_series
node_user -->|"requests metric"| node_metric_api
node_metric_api -->|"calculates"| node_basic_metrics
node_metric_api -->|"calculates"| node_structure_metrics
node_user -->|"provides"| node_raster
node_raster -->|"applies through time"| node_raster_apply
node_raster_apply -->|"applies metric"| node_metric_api
node_raster -->|"selects classes"| node_classify
node_classify -->|"converts to binary"| node_raster_apply
node_user -->|"runs benchmark"| node_benchmark
node_user -->|"plots results"| node_benchmark_plot

click node_classify "https://github.com/loganhysen/timescapes/blob/main/R/raster_metric.R"
click node_raster_apply "https://github.com/loganhysen/timescapes/blob/main/R/raster_metric.R"
click node_metric_api "https://github.com/loganhysen/timescapes/blob/main/R/registry.R"
click node_basic_metrics "https://github.com/loganhysen/timescapes/blob/main/R/metrics_basic.R"
click node_structure_metrics "https://github.com/loganhysen/timescapes/blob/main/R/metrics_structure.R"
click node_benchmark "https://github.com/loganhysen/timescapes/blob/main/R/benchmark_data.R"
click node_benchmark_plot "https://github.com/loganhysen/timescapes/blob/main/R/plot_benchmark.R"
click node_run_utils "https://github.com/loganhysen/timescapes/blob/main/R/utils.runs.R"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_series,node_raster,node_classify,node_raster_apply,node_user toneBlue
class node_metric_api,node_basic_metrics,node_structure_metrics toneAmber
class node_benchmark,node_benchmark_plot,node_run_utils toneMint
```

## Components

### Inputs and raster workflow

- **Binary time series**
- **Raster time stack**
- [Class to presence](https://github.com/loganhysen/timescapes/blob/main/R/raster_metric.R): `R/raster_metric.R`
- [Per-cell metric](https://github.com/loganhysen/timescapes/blob/main/R/raster_metric.R): `R/raster_metric.R`

### Temporal metrics

- [Metric interface](https://github.com/loganhysen/timescapes/blob/main/R/registry.R): `R/registry.R`
- [Basic metrics](https://github.com/loganhysen/timescapes/blob/main/R/metrics_basic.R): `R/metrics_basic.R`
- [Structure metrics](https://github.com/loganhysen/timescapes/blob/main/R/metrics_structure.R): `R/metrics_structure.R`

### Benchmarking

- [Benchmarking](https://github.com/loganhysen/timescapes/blob/main/R/benchmark_data.R): `R/benchmark_data.R`
- [Benchmark plotting](https://github.com/loganhysen/timescapes/blob/main/R/plot_benchmark.R): `R/plot_benchmark.R`
- [Benchmark utilities](https://github.com/loganhysen/timescapes/blob/main/R/utils.runs.R): `R/utils.runs.R`

### Other components

- **Package user**

## Connections

- Package user → Binary time series: provides (evidence: `README.md`)
- Package user → Metric interface: requests metric (evidence: `README.md`)
- Metric interface → Basic metrics: calculates (evidence: `README.md`)
- Metric interface → Structure metrics: calculates (evidence: `README.md`)
- Package user → Raster time stack: provides (evidence: `README.md`)
- Raster time stack → Per-cell metric: applies through time (evidence: `README.md`)
- Per-cell metric → Metric interface: applies metric (evidence: `README.md`)
- Raster time stack → Class to presence: selects classes (evidence: `README.md`)
- Class to presence → Per-cell metric: converts to binary (evidence: `README.md`)
- Package user → Benchmarking: runs benchmark (evidence: `README.md`)
- Package user → Benchmark plotting: plots results (evidence: `README.md`)
