# Part III: Snapping Points to NHD Flowline Data and Calculating River Distance with `riverdist`

Though it’s a bit late in getting posted, this is part III in a spatial series that is becoming a quasi-workshop in the variety of ways we can work with spatial river & stream data in R. This post will continue using the `sf`

package, and introduce the `riverdist`

package, but we’ll still be playing with data on rivers and streams.

To recap, in the first few posts we made a leaflet map, scraped data from tables on a webpage, demonstrated how to calculate distance matrices between point data, and showed how to use functions written by folks at USGS (OWI) as well as the Hydrosheds data to download riverline data. That’s a fair amount to chew on I realize, but I’d like to demo a few additional things that might be useful for folks working with river data.

**This post will ( try to) show you:**

- How to use the
`riverdist`

package to process a riverline network - How to snap spatial point data to the processed riverline data (which we downloaded in the previous post)
- Finally, how to calculate the river distance between sites (so along the river network)
- and a quick
`ggmap`

example

I think in a future post I’d like to demo how to implement a wavelet analysis of these flow data, as well as show an example of the very cool `geoknife`

package to assess patterns of river impairment. Onward!

So, hopefully these posts are useful and it doesn’t feel like this: