getChemDataSubsets: Chemical Data Subsets

Description Usage Arguments Details Value Examples

View source: R/getChemDataSubsets.R

Description

Get chemical data subsets.

Usage

1
2
getChemDataSubsets(TargetSiteID, comid, cluster, data.cluster,
  data.Stations.Info, data.chem.raw, data.chem.info)

Arguments

TargetSiteID

SiteID

comid

NHD+ COMID

cluster

cluster information for TargetSiteID. getSiteInfo list output 'COMID'.

data.cluster

data.cluster

data.Stations.Info

data.Stations.Info

data.chem.raw

Chemistry data.

data.chem.info

data.chem.info

Details

Summary information about chems.

Uses package reshape.

Required objects:

* data.cluster; COMID, H6_noland, H6_land, ElevWs, WsAreaSqKm, PrecipWs, TmeanWs, W___AGRIC, W___URBAN, W___FOREST

* data.Stations.Info; StationID_Master, FinalLatitude, FinalLongitude, WaterbodyName, GIS_County, CARefSite_2017, COMID_NHD2

* data.chem.raw; StationID_Master, ChemSampleID

* data.chem.info; Analyte

Value

A summary list; ref.sites, ref.reaches, cluster.samps, chem.info , all.chems, cluster.chem, and site.chem.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
TargetSiteID <- "SRCKN001.61"
dir_results <- file.path(getwd(), "Results")

# Data getSiteInfo
# data, example included with package
data.Stations.Info <- data_Sites       # need for getSiteInfo and getChemDataSubsets
data.SampSummary   <- data_SampSummary
data.303d.ComID    <- data_303d
data.bmi.metrics   <- data_BMIMetrics
data.algae.metrics <- data_AlgMetrics
data.mod           <- data_ReachMod

# Cluster based on elevation category  # need for getSiteInfo and getChemDataSubsets
elev_cat <- toupper(data.Stations.Info[data.Stations.Info[,"StationID_Master"]==TargetSiteID
                    , "ElevCategory"])
if(elev_cat=="HI"){
   data.cluster <- data_Cluster_Hi
} else if(elev_cat=="LO") {
   data.cluster <- data_Cluster_Lo
}

# Map data
# San Diego
#flowline <- rgdal::readOGR(dsn = "data_gis/NHDv2_Flowline_Ecoreg85", layer = "NHDv2_eco85_Project")
#outline <- rgdal::readOGR(dsn = "data_gis/Eco85", layer = "Ecoregion85")
# AZ
map_flowline  <- data_GIS_Flow_HI
map_flowline2 <- data_GIS_Flow_LO
if(elev_cat=="HI"){
   map_flowline <- data_GIS_Flow_HI
} else if(elev_cat=="LO") {
   map_flowline <- data_GIS_Flow_LO
}
map_outline   <- data_GIS_AZ_Outline
# Project site data to USGS Albers Equal Area
usgs.aea <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23
              +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83
              +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
# projection for outline
my.aea <- "+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 
           +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
map_proj <- my.aea

# Run getSiteInfo
list.SiteSummary <- getSiteInfo(TargetSiteID
                                , dir_results
                                , data.Stations.Info
                                , data.SampSummary
                                , data.303d.ComID
                                , data.bmi.metrics
                                , data.algae.metrics
                                , data.cluster
                                , data.mod
                                , map_proj
                                , map_outline
                                , map_flowline)

# Data getChemDataSubset
# data import, example 
# data.chem.raw <- read.delim(paste(myDir.Data, "data.chem.raw.tab", sep="")
                              , na.strings = c(""," "))
# data.chem.info <- read.delim(paste(myDir.Data, "data.chem.info.tab", sep=""))
# data, example included with package
#
site.COMID <- list.SiteSummary$COMID
site.Clusters <- list.SiteSummary$ClustIDs
data.chem.raw      <- data_Chem
data.chem.info     <- data_ChemInfo

# Run getChemDataSubsets
list.data <- getChemDataSubsets(TargetSiteID
                                , comid=site.COMID
                                , cluster=site.Clusters
                                , data.cluster=data.cluster
                                , data.Stations.Info=data.Stations.Info
                                , data.chem.raw=data.chem.raw
                                , data.chem.info=data.chem.info)

leppott/CASTfxn documentation built on Sept. 6, 2019, 11:04 p.m.