99# ' @param matched_sites sf object containing site locations and the flowline
1010# ' reach identifier ("COMID") that the site has been matched to. Must contain
1111# ' columns "COMID" and "geometry".
12+ # ' @param states_shp sf object containing the U.S. state boundaries to
13+ # ' include in the watershed plot.
1214# ' @param out_file character string indicating the name of the saved file,
1315# ' including file path and extension.
1416# ' @param huc6_select vector of character string(s) indicating the HUC6 basins that
3739# '
3840map_sites <- function (flowlines ,
3941 matched_sites ,
42+ states_shp ,
4043 out_file ,
4144 huc6_select = " 020402" ,
4245 basin_bbox = c(xmin = - 76.39556 , ymin = 39.5 , xmax = - 74.37121 , ymax = 40.89106 ),
@@ -109,7 +112,7 @@ map_sites <- function(flowlines,
109112 ggspatial :: annotation_scale(bar_cols = c(" gray70" ," white" ))
110113
111114 # create inset map
112- inset_map <- map_drb_watershed(matched_sites )
115+ inset_map <- map_drb_watershed(matched_sites , states_shp = states_shp )
113116
114117 # grab legend
115118 legend <- cowplot :: get_legend(sites_map )
@@ -145,10 +148,6 @@ map_sites <- function(flowlines,
145148# ' @param huc8 vector of character string(s) indicating the HUC8 basins that
146149# ' make up the watershed of interest. By default, the HUC8 basins that make up
147150# ' the Delaware River Basin will be used.
148- # ' @param states vector of character string(s) indicating which states should
149- # ' be included in the inset map, using two-letter postal code abbreviations for
150- # ' each state. By default, the states surrounding the Delaware River Basin will
151- # ' be downloaded, including "NY", "PA", "NJ", "DE", and "MD".
152151# ' @param epsg_out integer indicating the coordinate reference system that
153152# ' should be used when creating the inset map. Defaults to EPSG 3857, pseudo-
154153# ' mercator: https://epsg.io/3857
@@ -157,17 +156,14 @@ map_sites <- function(flowlines,
157156# ' Returns an inset map as a ggplot object.
158157# '
159158map_drb_watershed <- function (sites ,
159+ states_shp ,
160160 huc8 = c(" 02040101" ," 02040102" ," 02040103" ,
161161 " 02040104" ," 02040105" ," 02040106" ,
162162 " 02040201" ," 02040202" ," 02040203" ,
163163 " 02040204" ," 02040205" ," 02040206" ,
164164 " 02040207" ),
165- states = c(" NY" ," PA" ," NJ" ," DE" ," MD" ),
166165 epsg_out = 3857 ){
167166
168- # Download shapefiles for states that encompass the watershed of interest
169- states_shp <- USAboundaries :: us_states(resolution = " high" , states = states )
170-
171167 # Download HUC8 boundaries associated with watershed boundary
172168 boundary <- nhdplusTools :: get_huc8(id = huc8 ) %> %
173169 sf :: st_union()
@@ -191,6 +187,21 @@ map_drb_watershed <- function(sites,
191187}
192188
193189
190+ # ' @title Download state shapefiles
191+ # '
192+ # ' @param states vector of character string(s) indicating which states should
193+ # ' be included in the inset map, using two-letter postal code abbreviations for
194+ # ' each state. By default, the states surrounding the Delaware River Basin will
195+ # ' be downloaded, including "NY", "PA", "NJ", "DE", and "MD".
196+ # '
197+ get_state_shp <- function (states = c(" NY" ," PA" ," NJ" ," DE" ," MD" )){
198+
199+ # Download shapefiles for states that encompass the watershed of interest
200+ states_shp <- USAboundaries :: us_states(resolution = " high" , states = states )
201+
202+ }
203+
204+
194205# ' @title Create leaflet map of site locations
195206
196207# ' @description
0 commit comments