Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.86 KB

README.md

File metadata and controls

58 lines (43 loc) · 1.86 KB

vulnerabilityTools

The goal of vulnerabilityTools is to streamline some processes we need to run analyses in support of a national groundwater vulnerability model. Some of the functions in this package may prove useful for other applications utilizing SSURGO data and others as development evolves.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("ARMurray/vulnerabilityTools")

This package is in active development and is not released on CRAN

Example

This is a basic example which shows you how to create a flat file from the SSURGO horizons table. It takes the average value for all horizons within a component and then calculates weights by component based on percent of map unit. It then calculates the weighted average value for all horizons within a mapunit.

library(vulnerabilityTools)
library(USAboundaries)
library(sf)
library(tidyverse)
library(FedData)
ok <- us_states(resolution = "low")%>%   # Download all state boundaries
filter(name == "Oklahoma")%>%   # Filter to Oklahoma
  st_transform(crs = 32614) # Project to UTM 14N so distance units are in meters

 okgrid <- st_make_grid(ok,cellsize = 20000,    # 20,000 m cell size
                        square = FALSE)%>% # Returns sfc_POLYGON
   st_as_sf()
 okgrid$ID <- paste0("pt_",rownames(okgrid))
 colnames(okgrid) <- c("geometry","ID")
  st_geometry(okgrid) <- "geometry"

 sa <- okgrid[365,]%>%
    mutate(ID = "Ada")

 ada <- as_Spatial(sa)
 ssurgo <- get_ssurgo(ada, label = "Ada")
 weighted <- weightHorizons(ssurgo, "ksat.r")

 plot(weighted["muVar"], main = "Weighted ksat")