An open API service indexing awesome lists of open source software.

https://github.com/jsta/rinvest

R wrapper for Python invest
https://github.com/jsta/rinvest

python rstats

Last synced: about 1 year ago
JSON representation

R wrapper for Python invest

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# rinvest

[![R-CMD-check](https://github.com/jsta/rinvest/workflows/R-CMD-check/badge.svg)](https://github.com/jsta/rinvest/actions) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

## Installation

Requires that Anaconda (or Miniconda) be installed and that it can be detected by the `reticulate` package. Check if this is the case with:

```{r }
nchar(reticulate::conda_binary()) > 0
```

You can install `rinvest` with:

```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("jsta/rinvest")
rinvest::install_invest()
```

## Example

```{r example, eval=TRUE}
library(rinvest)

data_dir <- system.file("extdata/NDR", package = "rinvest")
args <- list(
"workspace_dir" = "workspace",
"dem_path" = paste0(data_dir, "/DEM_gura.tif"),
"lulc_path" = paste0(data_dir, "/land_use_gura.tif"),
"runoff_proxy_path" = paste0(data_dir, "/precipitation_gura.tif"),
"watersheds_path" = paste0(data_dir, "/watershed_gura.shp"),
"biophysical_table_path" = paste0(data_dir, "/biophysical_table_gura.csv"),
"calc_p" = TRUE,
"calc_n" = FALSE,
"threshold_flow_accumulation" = 1000,
"k_param" = 2,
"subsurface_eff_p" = 0.5,
"subsurface_critical_length_p" = 25
)

ndr_file_paths <- ndr(args, overwrite = TRUE)
```

```{r, eval=TRUE}
ndr_file_paths
```

```{r, eval=FALSE, message=FALSE}
library(raster)

plot(raster("workspace/p_surface_export.tif"), main = "P export")
```

![](man/figures/README-unnamed-chunk-4-1.png)

## Links

http://releases.naturalcapitalproject.org/invest-userguide/latest/

https://community.naturalcapitalproject.org/

https://github.com/natcap/invest