Skip to content

Commit 7d04315

Browse files
committed
Include updated stream points dataset. Remove RSA date filter. Use most recent dumpsite impact assessment
1 parent e6d7e7f commit 7d04315

File tree

11 files changed

+66
-90
lines changed

11 files changed

+66
-90
lines changed

R/dumpsites.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
#'
33
#' @param df_point Point data from Rapid Stream Assessment (RSA) dataset.
44
#' @param df_reach Reach data from Rapid Stream Assessment (RSA) dataset.
5-
#' @param start_date Beginning of timeframe being evaluated (ex. first day of
6-
#' five-year assessment period).
7-
#' @param end_date End of timeframe being evaluated (ex. last day of
8-
#' five-year assessment period).
95
#' @param reach_prefix_from_table Field name prefix sourced from RSA reach
106
#' attribute table. Should be consistent with the name of the stream reach
117
#' attribute table from the RSA geodatabase.
@@ -24,21 +20,18 @@
2420
#'
2521
#' @examples assess_dumpsites(df_point_example,
2622
#' df_reach_example,
27-
#' "2020-01-01",
28-
#' "2024-12-31",
2923
#' "StreamReachAttributes",
3024
#' "StreamReaches",
3125
#' "StreamPointAttributes",
3226
#' "StreamPoints_Intersect" )
3327

34-
assess_dumpsites <- function(df_point, df_reach, start_date, end_date, reach_prefix_from_table, reach_prefix_from_layer, point_prefix_from_table, point_prefix_from_layer){
28+
assess_dumpsites <- function(df_point, df_reach, reach_prefix_from_table, reach_prefix_from_layer, point_prefix_from_table, point_prefix_from_layer){
3529

3630
df_length <- df_reach %>%
3731
dplyr::select(location_name = dplyr::all_of(paste0(reach_prefix_from_layer, ".subshed")),
3832
reach_length = dplyr::all_of(paste0(reach_prefix_from_layer, ".Shape_Length")),
3933
id = dplyr::all_of(paste0(reach_prefix_from_table, ".featureGlobalID_key")),
4034
date = dplyr::all_of(paste0(reach_prefix_from_table, ".assessment_time"))) %>%
41-
dplyr::filter(date >= start_date & date <= end_date) %>%
4235
dplyr::group_by(id) %>%
4336
dplyr::slice_max(date, n=1, with_ties = FALSE) %>% # Remove duplicate reaches. Keep most recent reach assessment. If same date/time and ID, maintain only one record
4437
dplyr::ungroup() %>%
@@ -53,7 +46,7 @@ assess_dumpsites <- function(df_point, df_reach, start_date, end_date, reach_pre
5346
date = dplyr::all_of(paste0(point_prefix_from_table, ".assessment_time")),
5447
d_impact = dplyr::all_of(paste0(point_prefix_from_table, ".d_impact")),
5548
) %>%
56-
dplyr::filter(date >= start_date & date <= end_date) %>%
49+
tidyr::drop_na(d_impact) %>% # remove NA records in d_impact field. Likely assessments of existing points that did not change. Need to reference original record.
5750
dplyr::group_by(id) %>%
5851
dplyr::slice_max(date, n=1, with_ties = FALSE) %>% # Remove duplicate point. Keep most recent point assessment. If same date/time and ID, maintain only one record
5952
dplyr::ungroup() %>%

R/trash.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#' Calculate trash scores.
22
#'
33
#' @param df_reach Reach data from Rapid Stream Assessment (RSA) dataset.
4-
#' @param start_date Beginning of timeframe being evaluated (ex. first day of
5-
#' five-year assessment period).
6-
#' @param end_date End of timeframe being evaluated (ex. last day of
7-
#' five-year assessment period).
84
#' @param reach_prefix_from_table Field name prefix sourced from RSA reach
95
#' attribute table. Should be consistent with the name of the stream reach
106
#' attribute table from the RSA geodatabase.
@@ -15,11 +11,12 @@
1511
#' @return List of 2 dataframes: summary and score.
1612
#' @export
1713
#'
18-
#' @examples assess_trash(df_reach_example, "2020-01-01", "2024-12-31",
19-
#' "StreamReachAttributes", "StreamReaches")
14+
#' @examples assess_trash(df_reach_example,
15+
#' "StreamReachAttributes",
16+
#' "StreamReaches")
2017

2118

22-
assess_trash <- function(df_reach, start_date, end_date, reach_prefix_from_table, reach_prefix_from_layer) {
19+
assess_trash <- function(df_reach, reach_prefix_from_table, reach_prefix_from_layer) {
2320

2421
df_summary <- df_reach %>%
2522
dplyr::select(location_name = dplyr::all_of(paste0(reach_prefix_from_layer, ".subshed")),

R/wq_nutrients.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#' Calculate water quality scores for nutrients
22
#'
3-
#' @param df DOEE Ambient Water Quality Data that has been processed and formatted
4-
#' @param parameter_name String to indicate target parameter: "Nitrogen", "Phosphorus, Total (as P)"
5-
#' @param piedmont_criteria Nutrient criteria recommendation for Piedmont Ecoregion 64 in mg/L
6-
#' @param coastal_plain_criteria Nutrient criteria recommendation for Coastal Plain Ecoregion 65 in mg/L
3+
#' @param df DOEE Ambient Water Quality Data that has been processed and
4+
#' formatted
5+
#' @param parameter_name String to indicate target parameter: "Nitrogen",
6+
#' "Phosphorus, Total (as P)"
7+
#' @param piedmont_criteria Nutrient criteria recommendation for Piedmont
8+
#' Ecoregion 64 in mg/L
9+
#' @param coastal_plain_criteria Nutrient criteria recommendation for Coastal
10+
#' Plain Ecoregion 65 in mg/L
711
#'
812
#' @return List of three dataframes: results, summary, score
913
#' @export

data/StreamPoints_20241105_INT.xlsx

166 KB
Binary file not shown.

man/assess_dumpsites.Rd

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/assess_trash.Rd

Lines changed: 4 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/assess_wq_nutrients.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/all_scores.csv

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
"","sci_subshed","Trash","Dumpsites","Effective Impervious Area","Temperature, water","pH","Dissolved oxygen (DO)","Escherichia coli","Turbidity","Conductivity","Nitrogen","Phosphorus, Total (as P)","Connectivity","Fish","Habitat","Macroinvertebrates"
2-
"1","Battery Kemble Creek",8.43478260869565,10,6,10,10,10,7.17122657287291,10,1.32946707229891,1.1722461961956,10,10,3,4,7
3-
"2","Broad Branch",8.88235294117647,8,2,10,9.49484604605374,10,3.96201632162848,10,1.39551171022171,2.53189561427939,10,10,2,4,6
4-
"3","Dumbarton Oaks",10,10,4,10,10,10,8.54782802837774,10,1.70833294620897,1.32807710704536,2.8679579947462,10,3,5,7
5-
"4","Fenwick Branch",7.42857142857143,10,3,9.49476657878656,10,10,6.8791964501452,10,1.75285115573104,2.32427732195356,10,10,2,3,6
6-
"5","Fort Davis Tributary",8.33333333333333,2,2,10,10,10,4.56378937695466,3.40381314529514,1.28521704525446,0.950005376536892,1.78543632558786,1,1,5,5
7-
"6","Fort Dupont Tributary",7.64285714285714,7,8,10,10,8.19644566724721,4.39637929649141,3.667361623274,2.99612324159937,0.749069894299005,10,1,3,4,6
8-
"7","Fort Stanton Tributary",6.47058823529412,4,1,9.49458887028815,10,10,3.49306972579195,8.24161710963122,2.14961627380251,0.950005376536892,10,1,1,3,7
9-
"8","Foundry Branch",8.83333333333333,10,2,10,10,10,5.43588122762784,4.44089503244838,2.9615349603606,2.05698424129608,10,1,1,4,NA
10-
"9","Hickey Run",8.03846153846154,10,9,9.32570696570447,10,9.31006357105735,1.71733915151806,7.52739827502453,1.92353016456839,0.749069894299005,2.7927191991411,10,6,2,4
11-
"10","Klingle Valley Run",6.25,10,2,10,10,10,6.5392010054142,10,2.16336911176854,1.52948677601239,10,10,2,3,6
12-
"11","Luzon Branch",5.2,10,1,10,10,10,2.74149789121648,5.16856938057974,1.68139016788936,2.13654818496565,2.91985046082419,10,2,3,6
13-
"12","Normanstone Creek",7.21428571428571,10,1,10,8.9888961180284,10,4.46891175504634,10,1.49230558316491,2.58568816872641,10,10,3,3,6
14-
"13","Oxon Run",5.85714285714286,8,1,9.49482509665549,10,10,4.08034192298863,7.26446748330366,2.73668115439965,0.677223449104501,0.963293817107756,10,4,4,4
15-
"14","Pinehurst Branch",8.66666666666667,10,6,10,9.45561327204199,10,6.86529198320573,10,1.64381726305677,2.53189561427939,10,10,2,4,5
16-
"15","Piney Branch",8,10,1,10,10,10,6.24485935433058,10,1.37920467622303,2.43350524767764,10,10,3,2,4
17-
"16","Pope Branch",8,10,3,10,10,10,6.70307871860358,4.63848137391428,2.04750999680075,0.950005376536892,10,1,4,7,8
18-
"17","Portal Branch",7,10,3,10,8.98692894850945,10,4.24400479220216,6.90674993457207,1.02448007263146,2.74453544775747,10,10,1,3,6
19-
"18","Reservation 630",9.21052631578947,10,3,9.49484222518253,10,10,4.89875662885154,6.54810880322023,1.95694969141548,2.32427732195356,10,10,4,7,7
20-
"19","Rock Creek",8.23913043478261,7,1,9.03991429859265,9.63931584712039,10,4.75298766520739,8.85351874858907,3.01758638876789,2.35646823207748,10,10,5,4,5
21-
"20","Soapstone Creek",8.71428571428571,10,1,10,8.98764540312439,10,6.80566463860387,10,1.91408087817814,2.53189561427939,2.88434296861746,10,2,3,6
22-
"21","Texas Avenue Tributary",7,10,3,10,10,10,3.54658539291944,7.3375495518317,1.74050116850977,0.837784090876652,10,1,1,4,3
23-
"22","Watts Branch",3.55,6,1,9.32024027311975,9.03799489304956,9.94283156569335,3.52383649640539,8.10990235278729,2.71307679688268,0.80598894736693,4.92721388547487,10,4,3,6
24-
"23","Dalecarlia Tributary",NA,10,4,9.49281310022025,9.49429215204554,10,2.26543812278347,7.88130147148155,1.57723215112077,1.64140564675688,1.50035060003774,1,2,3,6
25-
"24","Fort Chaplin Tributary",NA,10,2,10,10,9.44055926057385,3.66863632512962,8.77121712686461,2.01955422326341,1.09628813677057,10,1,1,4,3
26-
"25","Nash Run",NA,10,3,8.97058038494947,9.49162145959481,10,2.85130675778872,8.98648127446675,3.13741218623777,1.09628813677057,10,10,6,5,4
1+
"","sci_subshed","Dumpsites","Effective Impervious Area","Temperature, water","pH","Dissolved oxygen (DO)","Escherichia coli","Turbidity","Conductivity","Nitrogen","Phosphorus, Total (as P)","Connectivity","Fish","Habitat","Macroinvertebrates"
2+
"1","Broad Branch",7,2,10,9.49484604605374,10,3.96201632162848,10,1.39551171022171,2.53189561427939,10,10,2,4,6
3+
"2","Fort Davis Tributary",1,2,10,10,10,4.56378937695466,3.40381314529514,1.28521704525446,0.950005376536892,1.78543632558786,1,1,5,5
4+
"3","Fort Dupont Tributary",2,8,10,10,8.19644566724721,4.39637929649141,3.667361623274,2.99612324159937,0.749069894299005,10,1,3,4,6
5+
"4","Fort Stanton Tributary",4,1,9.49458887028815,10,10,3.49306972579195,8.24161710963122,2.14961627380251,0.950005376536892,10,1,1,3,7
6+
"5","Normanstone Creek",4,1,10,8.9888961180284,10,4.46891175504634,10,1.49230558316491,2.58568816872641,10,10,3,3,6
7+
"6","Oxon Run",8,1,9.49482509665549,10,10,4.08034192298863,7.26446748330366,2.73668115439965,0.677223449104501,0.963293817107756,10,4,4,4
8+
"7","Pinehurst Branch",7,6,10,9.45561327204199,10,6.86529198320573,10,1.64381726305677,2.53189561427939,10,10,2,4,5
9+
"8","Rock Creek",7,1,9.03991429859265,9.63931584712039,10,4.75298766520739,8.85351874858907,3.01758638876789,2.35646823207748,10,10,5,4,5
10+
"9","Watts Branch",5,1,9.32024027311975,9.03799489304956,9.94283156569335,3.52383649640539,8.10990235278729,2.71307679688268,0.80598894736693,4.92721388547487,10,4,3,6
11+
"10","Battery Kemble Creek",10,6,10,10,10,7.17122657287291,10,1.32946707229891,1.1722461961956,10,10,3,4,7
12+
"11","Dalecarlia Tributary",10,4,9.49281310022025,9.49429215204554,10,2.26543812278347,7.88130147148155,1.57723215112077,1.64140564675688,1.50035060003774,1,2,3,6
13+
"12","Dumbarton Oaks",10,4,10,10,10,8.54782802837774,10,1.70833294620897,1.32807710704536,2.8679579947462,10,3,5,7
14+
"13","Foundry Branch",10,2,10,10,10,5.43588122762784,4.44089503244838,2.9615349603606,2.05698424129608,10,1,1,4,NA
15+
"14","Fort Chaplin Tributary",10,2,10,10,9.44055926057385,3.66863632512962,8.77121712686461,2.01955422326341,1.09628813677057,10,1,1,4,3
16+
"15","Fenwick Branch",10,3,9.49476657878656,10,10,6.8791964501452,10,1.75285115573104,2.32427732195356,10,10,2,3,6
17+
"16","Hickey Run",10,9,9.32570696570447,10,9.31006357105735,1.71733915151806,7.52739827502453,1.92353016456839,0.749069894299005,2.7927191991411,10,6,2,4
18+
"17","Klingle Valley Run",10,2,10,10,10,6.5392010054142,10,2.16336911176854,1.52948677601239,10,10,2,3,6
19+
"18","Luzon Branch",10,1,10,10,10,2.74149789121648,5.16856938057974,1.68139016788936,2.13654818496565,2.91985046082419,10,2,3,6
20+
"19","Reservation 630",10,3,9.49484222518253,10,10,4.89875662885154,6.54810880322023,1.95694969141548,2.32427732195356,10,10,4,7,7
21+
"20","Nash Run",10,3,8.97058038494947,9.49162145959481,10,2.85130675778872,8.98648127446675,3.13741218623777,1.09628813677057,10,10,6,5,4
22+
"21","Pope Branch",10,3,10,10,10,6.70307871860358,4.63848137391428,2.04750999680075,0.950005376536892,10,1,4,6,8
23+
"22","Portal Branch",10,3,10,8.98692894850945,10,4.24400479220216,6.90674993457207,1.02448007263146,2.74453544775747,10,10,1,3,6
24+
"23","Piney Branch",10,1,10,10,10,6.24485935433058,10,1.37920467622303,2.43350524767764,10,10,3,2,4
25+
"24","Soapstone Creek",10,1,10,8.98764540312439,10,6.80566463860387,10,1.91408087817814,2.53189561427939,2.88434296861746,10,2,3,6
26+
"25","Texas Avenue Tributary",10,3,10,10,10,3.54658539291944,7.3375495518317,1.74050116850977,0.837784090876652,10,1,1,5,3

vignettes/figures/rsa_join.png

-1.86 KB
Loading

vignettes/pre-processing.Rmd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ knitr::opts_chunk$set(
2020

2121
- The R functions assess_trash() and assess_dumpsites() require dataframe inputs of processed RSA reach data and RSA point data (dumpsites only)
2222

23-
- The watershed layer included in RSA database was not used due to issue found. For example, layer "Watersheds_Notes_RSA2021" has missing area in Rock Creek. Instead used: [DC Subwatersheds  Open Data Layer](https://opendata.dc.gov/datasets/dc-subwatersheds/explore?location=38.890772%2C-77.021832%2C12.98&showTable=true).
23+
- The watershed layer included in RSA database was not used due to issue found. For example, layer "Watersheds_Notes_RSA2021" has missing area in Rock Creek. Instead used: [DC Subwatersheds Open Data Layer](https://opendata.dc.gov/datasets/dc-subwatersheds/explore?location=38.890772%2C-77.021832%2C12.98&showTable=true).
2424

2525
<br>
2626

@@ -34,26 +34,29 @@ knitr::opts_chunk$set(
3434

3535
- This step is needed so that the GlobalID information will be included in the intersected table
3636

37-
2. Intersect [DC Subwatersheds  Open Data Layer](https://opendata.dc.gov/datasets/dc-subwatersheds/explore?location=38.890772%2C-77.021832%2C12.98&showTable=true) with StreamPoints layer
37+
2. Intersect [DC Subwatersheds Open Data Layer](https://opendata.dc.gov/datasets/dc-subwatersheds/explore?location=38.890772%2C-77.021832%2C12.98&showTable=true) with StreamPoints layer
3838

39-
3. Run the 'Add Attribute Index' tool:
39+
3. Run the 'Add Attribute Index' tool on the Intersected layer so that ID field is indexed:
4040

4141
- Field to Index: GlobalID_copy
4242

4343
- Index Name: GlobalID_index
4444

4545
4. Join StreamPoints attributes table to StreamPoints feature layer. See settings in screenshot below:
4646

47+
- If 'One to Many" Join Operation not an option, make sure attribute table and feature layer are in the same geodatabase
48+
4749
![](figures/rsa_join.png){width="326"}
4850

49-
5. Export joined StreamPoints table to Excel
51+
5. Export joined StreamPoints by using 'Table to Excel' geoprocessing tool
5052

5153
- Save file to R package data folder
54+
5255
- Update file name input variable in workflow.R file
5356

5457
6. In the input variables section of workflow.R, update the field name prefix variables (if needed)
5558

56-
7. Repeat steps 1, 3,4, 5 and 6 using StreamReaches feature layer and attribute table
59+
7. Repeat steps 1, 3, 4, 5 and 6 using StreamReaches feature layer and attribute table
5760

5861
- Skip Step 2 since subshed information is already included as a field in the StreamReaches feature layer
5962

0 commit comments

Comments
 (0)