
<!-- README.md is generated from README.Rmd. Please edit that file -->

# cdlsim

<!-- badges: start -->

[![R-CMD-check](https://github.com/burgerhaley97/cdlsim/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/burgerhaley97/cdlsim/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of cdlsim is to simulate USDA CDL data to quantify the
sensitivity of metrics calculated on it. The R package landscapemetrics
is used to implement popular FRAGSTATS style metrics in R.

## Installation

The stable release of **cdlsim** will be available from
[CRAN](https://CRAN.R-project.org) soon:

``` r
install.packages("cdlsim")
```

Until then, you can install the development version of cdlsim from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("burgerhaley97/cdlsim")
```

## Example Usage

This is a basic example which shows how a simple landscape would behave
in our simulation:

library(cdlsim)

# Create a small raster
r <- rast(nrows = 20, ncols = 20)
values(r) <- rep(1:3, length.out = ncell(r))

# Simple transition matrix
trans_mat <- matrix(1/3, nrow = 3, ncol = 3)
rownames(trans_mat) <- colnames(trans_mat) <- c("1", "2", "3")

# Simulation example
simulate_raster_patch(r, trans_mat, iterations = 1)

<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />
