DOI-USGS / dataRetrieval

This R package is designed to obtain USGS or EPA water quality sample data, streamflow data, and metadata directly from web services.
https://doi-usgs.github.io/dataRetrieval/
Other
256 stars 85 forks source link

How to pull all site data from an entire state from readNWISsite #673

Closed kellygarvey closed 9 months ago

kellygarvey commented 9 months ago

Hi, I am interested in pulling all of the sites from one state from the readNWISsite function. It only takes in one argument so I am unsure how to specify the range of sites for one state (Is there a list?). I haven't found many forums/ questions online about this particular function of the readNWISsite function so I would like some advice if possible. Thank you so much - this is an amazing package and I look forward to using it.

ldecicco-USGS commented 9 months ago

If you want to query by state, you'll need to use either readNWISdata with the service = "site" argument, or whatNWISdata.

wi <- readNWISdata(stateCd = "WI", service = "site")
wi2 <- whatNWISdata(stateCd = "WI")

You can try those and see the difference. There's a lot more information about what data is available at each site from the whatNWISdata function. You could also do bounding boxes, or query by county. You can add more query arguments to those functions as well.

Here's a recent tutorial. It's a bit WQP focused, but there's still NWIS stuff towards the end. https://rconnect.usgs.gov/NMC_dataRetrieval_1/dataRetrieval_1.html

The part that might be of interest for you is here: https://rconnect.usgs.gov/NMC_dataRetrieval_1/dataRetrieval_1.html#/readnwisdata-generalized-retrieval

kellygarvey commented 9 months ago

Hi! Thank you so much for this information. I see what you mean about the differences between readNWISdata and whatNWISdata.

I am looking to download all sites that have aquifer information (nat_aqfr_cd) which I believe is a column only in the readNWISsite function (not looking for sites without aquifer information). Is there a way to call an entire state from this function? Or will I need to use readNWISdata and whatNWISdata in some kind of conjunction with it?

Thank you so much for your time and help! :)

ldecicco-USGS commented 9 months ago

Try this:

x <- readNWISdata(stateCd = "WI", 
             siteOutput = "Expanded", 
             service = "site")

You can see other possibilities for queries here: https://waterservices.usgs.gov/rest/Site-Test-Tool.html

kellygarvey commented 9 months ago

This works amazing! Thank you so much for your help and time on this! :)