https://github.com/brownag/rapr
Interface to Rangeland Analysis Platform (RAP) Vegetation Biomass and Cover Products
https://github.com/brownag/rapr
Last synced: 2 months ago
JSON representation
Interface to Rangeland Analysis Platform (RAP) Vegetation Biomass and Cover Products
- Host: GitHub
- URL: https://github.com/brownag/rapr
- Owner: brownag
- License: gpl-3.0
- Created: 2022-02-26T01:21:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-01T19:38:51.000Z (8 months ago)
- Last Synced: 2025-03-17T17:04:36.738Z (2 months ago)
- Language: R
- Homepage: http://humus.rocks/rapr/
- Size: 18.4 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.retina = 3,
fig.path = "man/figures/README-",
out.width = "100%"
)
```# rapr
[](https://codecov.io/gh/brownag/rapr?branch=main)
[](https://humus.rocks/rapr/)
[](https://github.com/brownag/rapr/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/brownag/rapr?branch=main)The goal of {rapr} is to provide a simple R interface to Rangeland Analysis Platform (RAP) Vegetation Biomass and Cover Products. See https://rangelands.app/products and `citation("rapr")` for more information on these products.
You can query annual biomass and cover (versions 2 and 3) for the years 1986 to present.
- `product = "vegetation-biomass"` returns two layers for each year:
- `"annual forb and grass"`, `"perennial forb and grass"` (**lbs / acre**).
- `product = "vegetation-cover"` returns six layers for each year:
- `"annual forb and grass"`, `"bare ground"`, `"litter"`, `"perennial forb and grass"`, `"shrub"`, `"tree"` (**% cover**)## Installation
You can install the development version of {rapr} from [GitHub](https://github.com/brownag/rapr) with:
``` r
# install.packages("remotes")
remotes::install_github("brownag/rapr")
```## Example
This example shows how to use a {[terra](https://github.com/rspatial/terra)} SpatVector containing a rectangular polygon with `rapr::get_rap()` to obtain RAP grids for the corresponding extent.
{[terra](https://cran.r-project.org/package=terra)}, {[raster](https://cran.r-project.org/package=raster)}, {[sf](https://cran.r-project.org/package=sf)} and {[sp](https://cran.r-project.org/package=sp)} objects are all supported input types. Any spatial object used should have its Coordinate Reference System defined, as the input coordinates will be projected to the source data Coordinate Reference System of the RAP grids (WGS84 decimal degrees / `"EPSG:4326"`).
```{r example}
library(terra)
library(rapr)res <- get_rap(
vect("POLYGON ((-120 36.99,-119.99 37,-120 37,-120 36.99))",
crs = "EPSG:4326"),
version = "v3",
year = c(1986, 1996, 2006, 2016),
progress = FALSE
)res
plot(res)
```When a `filename` argument is not specified, unique temporary files will be generated. The resulting SpatRaster object will retain reference to these files, and you can remove them manually with `unlink(terra::sources())`.
When a `filename` _is_ specified, temporary files will be removed after the result (often a multi- year/layer/product) SpatRaster is written to new file.In lieu of a spatial object from {terra}, {raster}, {sf} or {sp} packages you may specify a bounding box using a numeric vector containing `xmin`, `ymax`, `xmax`, `ymin` in WGS84 longitude/latitude decimal degrees (corresponding to order used in `gdal_translate` `-projwin` option). e.g. `get_rap(x = c(-120, 37, -119.99, 36.99), ...)`.
```
(1: xmin, 2: ymax)--------------------------|
| |
| TARGET EXTENT |
| x = c(xmin, ymax, xmax, ymin) |
| |
|---------------------------(3: xmax, 4: ymin)
```## Citation
```{r, echo=FALSE}
citation("rapr")
```