This repository provides a set of R and Python scripts to process data from vegetation surveys and to create the Indicator Explorer for AIM NPR-A R Shiny app. The data processed includes plot-level data on foliar cover, environment and soils, and plot photos.
The primary goal of this project is to use field-based data to create a R Shiny app to be used during Bureau of Land Management's AIM NPR-A Benchmarks Workshop held in Fairbanks in spring 2024. The Shiny app serves as a user-friendly interface for visualizing, exploring, and analyzing the processed ecological data, making complex datasets accessible to scientists and land managers.
The scripts handle various stages of data preparation, including querying and processing data from the AKVEG Database, creating a classification schema to categorize plots, and processing and integrating plot photos into HTML pages. The processed outputs are then integrated into an R Shiny app, where they are used to create maps, visualizations, and summary tables.
This project is built using the following software and packages:
Python
- Python 3.9+
ospandasrepathlib
R
- R 4.0.0+
tidyversepackages:dplyr,readr,readxl,stringr,tibble,tidyr,purrrfsRPostgresDTleafletplotlyRColorBrewershinyshinyjsshinythemesshinyWidgets
Follow these simple steps to run the scripts on your local machine.
Before you begin, ensure you have the following:
- Git: For cloning the repository.
- Database credentials: The AKVEG Database is a cloud-based, PostgreSQL database that contains standardized vegetation data of more than 34,000 plots in Alaska . You can request server credentials to access the database by visiting the AKVEG website.
- R Shiny app inputs: Alternatively, if you are only interested in reproducing the R Shiny app, download the Shiny app inputs (ZIP file). After cloning the repository and installing the required R packages, replace the contents of the 'www' folder with the contents of the ZIP file. Doing so will allow you to run the R Shiny app on your local machine.
- Google Cloud virtual machine: If you are interested in replicating the R Shiny app on a server, you will need access to a Google Cloud virtual machine (or similar) on which you can install R, R Studio Server, and Shiny Server.
-
Clone the repository: Open your terminal or command prompt and clone the project repository to your local machine using Git:
git clone https://github.com/accs-uaa/aim-npra-benchmarks.git
-
Install dependencies: Ensure that you have the programming languages and packages that are listed in Built With section installed on your local machine.
- Prepare your input files
Ensure that your database credentials or app inputs are located in a directory on your local computer.
- Configure script file paths
Each R and Python script in this repository includes variables at the top of the script that define input and output file paths. You will need to modify these paths to correctly point to the locations on your computer where your input files are stored and where you want the processed outputs to be saved.
- Execute the processing scripts
The scripts are numbered to guide you through the correct execution order. Simply run them sequentially, following the numerical order. For example, start with scripts labeled 01_..., then 02_..., and so on. Each script performs a specific processing step, ensuring your data is ready for the next stage of the workflow.
- View your R Shiny app locally
Once all the processing scripts have been successfully executed and the necessary data are prepared, you can launch and view the R Shiny application.
- Using RStudio: Open the
app.Rfile in RStudio. Then, click the "Run App" button located in the top-right corner of the script editor pane. - From an R console: Navigate your R console to the directory containing the
app.R file, and then runshiny::runApp().
The Shiny app will automatically open in your default web browser, allowing you to interact with the data and explore plot locations, visualizations, and summary tables.
- Deploy your R Shiny app
Follow the instructions in gcloud_shiny.md if you would like to set up a virtual machine to serve your R Shiny app.
This project is provided under the GNU General Public License v3.0. It is free to use and modify in part or in whole.
- Project Maintainer: Amanda Droghini
- Email: adroghini (at) alaska.edu
- GitHub: @adroghini
