Failing split catchment call.
Taher Chegini got in touch about this failing NWIS site.
library(nhdplusTools)
#> USGS Support Package: https://owi.usgs.gov/R/packages.html#support
site <- "USGS-01017060"
nldi_f <- get_nldi_feature(list(featureSource = "nwissite",
featureID = site))
fline <- subset_nhdplus(as.numeric(nldi_f$comid), nhdplus_data = "download")
#> All intersections performed in latitude/longitude.
#> Reading NHDFlowline_Network
#> Writing NHDFlowline_Network
fline <- sf::st_cast(fline$NHDFlowline_Network, "LINESTRING")
(ind <- get_flowline_index(fline, nldi_f))
#> Warning in get_flowline_index(fline, nldi_f): crs of lines and points don't
#> match. attempting st_transform of points
#> # A tibble: 1 x 5
#> id COMID REACHCODE REACH_meas offset
#> <int> <int> <chr> <dbl> <dbl>
#> 1 1 802939 01010004001307 75.3 0.00163
(p <- nhdplusTools::get_hydro_location(ind, dplyr::select(fline, COMID = comid,
FromMeas = frommeas,
ToMeas = tomeas)))
#> Geometry set for 1 feature
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -67.98753 ymin: 46.78361 xmax: -67.98753 ymax: 46.78361
#> Geodetic CRS: NAD83
#> POINT (-67.98753 46.78361)
(b <- nhdplusTools::get_split_catchment(p, upstream = FALSE))
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -67.99435 ymin: 46.77566 xmax: -67.96994 ymax: 46.78989
#> Geodetic CRS: WGS 84
#> # A tibble: 2 x 3
#> id catchmentID geometry
#> <chr> <chr> <POLYGON [°]>
#> 1 catchment 802939 ((-67.98531 46.77673, -67.98606 46.77732, -67.9882~
#> 2 splitCatchment <NA> ((-67.98731 46.78989, -67.98742 46.78963, -67.9877~
b <- sf::st_transform(b, 3857)
plot_nhdplus(list(as.integer(nldi_f$comid)))
#> Zoom: 13
#> Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
#> Audotdetect projection: assuming Google Mercator (epsg 3857)
plot(b[b$id == "catchment", ], col = NA, border = "red", add = TRUE)
plot(b[b$id == "splitCatchment", ], col = NA, border = "green", add = TRUE)
basin <- nhdplusTools::get_nldi_basin(list(featureSource = "nwissite",
featureID = site))
plot(sf::st_transform(basin, 3857),
col = NA, border = "brown", add = TRUE)
(b <- nhdplusTools::get_split_catchment(p, upstream = TRUE))
#> Request failed [502]. Retrying in 1 seconds...
#> Request failed [502]. Retrying in 1 seconds...
#> Error calling processing service.
#> Original error:
#> Error in doTryCatch(return(expr), name, parentenv, handler): <html>
#> <head><title>502 Bad Gateway</title></head>
#> <body>
#> <center><h1>502 Bad Gateway</h1></center>
#> </body>
#> </html>
#> NULL
Created on 2021-11-10 by the reprex package (v2.0.0)