Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Description: Tools for using the 'StreamCat' and 'LakeCat' API and
Depends: R (>= 4.1.0)
Imports:
sf,
nhdplusTools,
hydrogeofetch,
jsonlite,
httr2,
curl (>= 6.0.0),
Expand Down
6 changes: 3 additions & 3 deletions R/lc_get_comid.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @param crsys The epsg code if using a raw data frame
#'
#' @param buffer The amount of buffer to use to extend search for a waterbody
#' (simply passed to nhdplusTools::get_waterbodies)
#' (simply passed to hydrogeofetch::get_waterbodies)
#'
#' @return A new sf data frame with a populated 'COMID' column
#'
Expand Down Expand Up @@ -56,9 +56,9 @@ lc_get_comid <- function(dd = NULL, xcoord = NULL,

output <- do.call(rbind, lapply(1:nrow(dd), function(i){
if (is.null(buffer)){
wb <- nhdplusTools::get_waterbodies(dd[i,])
wb <- hydrogeofetch::get_waterbodies(dd[i,])
} else {
wb <- nhdplusTools::get_waterbodies(dd[i,], buffer=buffer)
wb <- hydrogeofetch::get_waterbodies(dd[i,], buffer=buffer)
}
if (!is.null(wb)){
comid <- wb |>
Expand Down
2 changes: 1 addition & 1 deletion R/sc_get_comid.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sc_get_comid <- function(dd = NULL, xcoord = NULL,
geom_col <- attr(dd, "sf_column")
run_for <- 1:nrow(dd)
output <- do.call(rbind, lapply(1:nrow(dd), function(i){
comid <- nhdplusTools::discover_nhdplus_id(dd[i,c(geom_col)])
comid <- hydrogeofetch::discover_nhdplus_id(dd[i,c(geom_col)])
if (length(comid)==0L) comid <- NA else comid <- comid
return(comid)
}))
Expand Down
2 changes: 1 addition & 1 deletion R/sc_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ sc_plotnni <- function(comid, include.nue = FALSE, include.inset = TRUE){

#comid
comidint <- as.integer(comid)
flowline <- nhdplusTools::get_nhdplus(comid = comidint, realization = "flowline")
flowline <- hydrogeofetch::get_nhdplus(comid = comidint, realization = "flowline")
point <- flowline |>
sf::st_geometry() |>
sf::st_centroid() |>
Expand Down
2 changes: 1 addition & 1 deletion man/lc_get_comid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vignettes/Articles/Applications.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ knitr::opts_chunk$set(
```

### Plotting watershed data
In this example we access a single variable for the Calapooia River using `sc_get_data` function. We then use the `nhdplusTools` library to grab flowlines and watershed for the Calapooia, plot the selected StreamCat metric for the Calapooia River and show the watershed.
In this example we access a single variable for the Calapooia River using `sc_get_data` function. We then use the `hydrogeofetch` library to grab flowlines and watershed for the Calapooia, plot the selected StreamCat metric for the Calapooia River and show the watershed.
```{r wshd, results='hide'}
library(StreamCatTools)
start_comid = 23763517
nldi_feature <- list(featureSource = "comid", featureID = start_comid)

flowline_nldi <- nhdplusTools::navigate_nldi(nldi_feature, mode = "UT", data_source = "flowlines", distance=5000)
flowline_nldi <- hydrogeofetch::navigate_nldi(nldi_feature, mode = "UT", data_source = "flowlines", distance=5000)

# get StreamCat metrics
df <- sc_get_data(metric='pctimp2011', aoi='cat', comid=flowline_nldi$UT_flowlines$nhdplus_comid)
Expand All @@ -45,7 +45,7 @@ df <- sc_get_data(metric='pctimp2011', aoi='cat', comid=flowline_nldi$UT_flowlin
flowline_nldi <- flowline_nldi$UT_flowlines
flowline_nldi$PCTIMP2011CAT <- df$pctimp2011cat[match(flowline_nldi$nhdplus_comid, df$comid)]

basin <- nhdplusTools::get_nldi_basin(nldi_feature = nldi_feature)
basin <- hydrogeofetch::get_nldi_basin(nldi_feature = nldi_feature)
```

```{r wshd pt2}
Expand All @@ -64,7 +64,7 @@ dplyr::glimpse(nrsa)
# Promote data frame to sf spatial points data frame
nrsa_sf <- sf::st_as_sf(nrsa, coords = c("LON_DD83", "LAT_DD83"), crs = 4269)

# Get COMIDs using nhdplusTools package
# Get COMIDs using hydrogeofetch package
# nrsa$COMID<- NA
# for (i in 1:nrow(nrsa_sf)){
# print (i)
Expand Down
6 changes: 3 additions & 3 deletions vignettes/Articles/LakeCat.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ head(metrics)
```

## Get Waterbody COMIDs
In this example we use the `lc_get_comid` function to find COMIDs for a set of example lake locations we load into R.`lc_get_comid` is just a simple wrapper for `get_waterbodies` in the [nhdplusTools](https://doi-usgs.github.io/nhdplusTools/) R package. We can then use the COMIDs we derive for our lake locations to get LakeCat metrics for these lakes as we show in after this.
In this example we use the `lc_get_comid` function to find COMIDs for a set of example lake locations we load into R.`lc_get_comid` is just a simple wrapper for `get_waterbodies` in the [hydrogeofetch](https://doi-usgs.github.io/hydrogeofetch/) R package. We can then use the COMIDs we derive for our lake locations to get LakeCat metrics for these lakes as we show in after this.
```{r comids, warning=FALSE, message=FALSE}
dd <- data.frame(x = c(-89.198,-114.125,-122.044),
y = c(45.502,47.877,43.730)) |>
Expand Down Expand Up @@ -117,10 +117,10 @@ knitr::kable(df)

## Get lake and lake watersheds as `sf` objects

`StreamCatTools` includes a function `lc_get_watershed` that will return the watershed of any lake by COMID from an AWS S3 bucket of partitioned geoparquet files for all LakeCat lake watersheds (both on-network and off-network lakes). The watershed requested is returned as an `sf` object and uses `duckDB` as well as optional parallelization for faster data returns and specification of a specific HUC2 if known to reduce search time. **NOTE** `lc_get_watershed` currently only returns one watershed per request. This can be used in conjunction with `nhdplusTools` function `get_waterbodies` to map lake features for which `LakeCat` metrics are requested as shown below.
`StreamCatTools` includes a function `lc_get_watershed` that will return the watershed of any lake by COMID from an AWS S3 bucket of partitioned geoparquet files for all LakeCat lake watersheds (both on-network and off-network lakes). The watershed requested is returned as an `sf` object and uses `duckDB` as well as optional parallelization for faster data returns and specification of a specific HUC2 if known to reduce search time. **NOTE** `lc_get_watershed` currently only returns one watershed per request. This can be used in conjunction with `hydrogeofetch` function `get_waterbodies` to map lake features for which `LakeCat` metrics are requested as shown below.

```{r get_lake}
lake <- nhdplusTools::get_waterbodies(id = 19334077)
lake <- hydrogeofetch::get_waterbodies(id = 19334077)
```

```{r get_watershed}
Expand Down
6 changes: 3 additions & 3 deletions vignettes/Articles/NNI.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ tibble::tibble(sc_get_nni(year='2017', comid=com, aoi='cat,ws'))


## Plot a single NNI metric for a given watershed
In this example we access a single National Nutrient Inventory (NNI) metric for the Calapooia River basin using the `sc_get_data` function. We use the `nhdplusTools` library to pull in flowlines and the watershed boundary for the Calapooia River basin, plot the selected NNI metric for the Calapooia River and show the watershed.
In this example we access a single National Nutrient Inventory (NNI) metric for the Calapooia River basin using the `sc_get_data` function. We use the `hydrogeofetch` library to pull in flowlines and the watershed boundary for the Calapooia River basin, plot the selected NNI metric for the Calapooia River and show the watershed.
```{r farmn, results='hide'}
start_comid = 23763517
nldi_feature <- list(featureSource = "comid", featureID = start_comid)

flowline_nldi <- nhdplusTools::navigate_nldi(nldi_feature, mode = "UT", data_source = "flowlines", distance=5000)
flowline_nldi <- hydrogeofetch::navigate_nldi(nldi_feature, mode = "UT", data_source = "flowlines", distance=5000)

# get StreamCat metrics
comids <- paste(as.integer(flowline_nldi$UT_flowlines$nhdplus_comid), collapse=",",sep="")
Expand All @@ -203,7 +203,7 @@ df <- sc_get_data(metric='n_ff_2016', aoi='cat', comid=comids, showAreaSqKm=TRUE
flowline_nldi <- flowline_nldi$UT_flowlines
flowline_nldi$Farm_Nitrogon_2016 <- df$n_ff_2016cat[match(flowline_nldi$nhdplus_comid, df$comid)]

basin <- nhdplusTools::get_nldi_basin(nldi_feature = nldi_feature)
basin <- hydrogeofetch::get_nldi_basin(nldi_feature = nldi_feature)
```

## Map the Results
Expand Down