DOI-USGS / nhdplusTools

See official repository at: https://code.usgs.gov/water/nhdplusTools
https://doi-usgs.github.io/nhdplusTools/
Creative Commons Zero v1.0 Universal
84 stars 32 forks source link

Interest in working AOI into get_nhd() and subset_nhd() workflows? #90

Closed mikejohnson51 closed 4 years ago

mikejohnson51 commented 5 years ago

This is to gage interest in a pull request leveraging the AOI package to facilitate bringing in NHD data from the CIDA server. Advantages are the abilty to describe regions by common place names, spatial (sf/sp/raster) files, nwis ids, or COMIDs.

AOI will soon be on CRAN and a pull request would look very much like this from HydroData.

library(HydroData)
#> Loading required package: AOI
#> Loading required package: leaflet
test1 = getAOI('UCSB') %>% findNHD()
#> Returned object contains: 19 nhd flowlines
plot(test1$nhd$geometry, col = "blue", lwd = test1$nhd$streamorde)
plot(test1$AOI$geometry, border = 'red', add = T)


test2 = findNHD(comid = 101)
#> Returned object contains: 1 nhd flowlines
plot(test2$nhd$geometry)


test3 = findNHD(nwis = 11407000)
#> Returned object contains: 1 nhd flowlines
plot(test3$nhd$geometry)


test4 = getAOI(list('Yellowstone National Park', 30, 30)) %>% findNHD(streamorder = 4)
#> Returned object contains: 41 nhd flowlines
unique(test4$nhd$streamorde)
#> [1] 5 4
plot(test4$nhd$geometry)

Created on 2019-09-14 by the reprex package (v0.3.0)

Thanks!

dblodgett-usgs commented 5 years ago

I'm very interested. I like the idea of some convenience functions that help use the building blocks I've got here in nhdplusTools. What are you thinking in particular?

mikejohnson51 commented 5 years ago

If I have adequately read through the nhdplusTools functonality, it would be to (1) extend get_nhdplus_bybox to get NHD flowlines (in addition to NHDArea and NHDWaterbodies) by spatial feature subsetting; (2) add a geocoding front to 'get_nhdplus_point'; and (3) add some addtional filters for things like stream order.

Moreover I suppose it would be integrating the bybox, bypoint and by_id calls into a single function (?get_nhdplus?) that would select the needed process from the user provided inputs.

dblodgett-usgs commented 4 years ago

Going to be merging my latest work on plot_nhdplus() and the currently unexported get_plot_data() functions. They not take a bbox rather than outlets -- which is an ideal hook for use with AOI.

I wonder if we could look at porting some of the HydroData functionality over here so you don't have to maintain it there? Would be an easy way to get some of the logic you have there onto CRAN without jumping through that hoop.

Have a look at this latest stuff in the plot_nhdplus.R file and see what you think. I'm about ready for a major refactor just to clean house, but in general this is all coming together nicely and I see how the stuff you've been doing could fit really well.

mikejohnson51 commented 4 years ago

Closing as this would be covered by #155