Closed ghost closed 6 months ago
Thanks for the submission! We're consider adding this or something like it eventually. I want to get a bug fix out to CRAN in the near term, but I'll have a look at this in the next couple of weeks.
My initial thought is that we can currently use the "queryTime" attribute that is attached to each dataset to produce the bibliography at some later point in the script:
library(dataRetrieval)
df <- readNWISdv("05212700", "00060", "2021-01-01","2021-01-07")
attr(df, "queryTime")
[1] "2022-02-10 14:39:15 CST"
# or
format(attr(df, "queryTime"), format = "%b %d, %Y")
[1] "Feb 10, 2022"
Another thought I'm having reading this suggestion, maybe we should create output similar to the citation
function. This would then allow R users to create Bibtex outputs or use other tools that are built around that output. So instead of:
cite_dataRetrieval <- citation("dataRetrieval")
toBibtex(cite_dataRetrieval )
@Manual{,
author = {Laura A. {De Cicco} and David Lorenz and Robert M. Hirsch and William Watkins and Mike Johnson},
title = {dataRetrieval: R packages for discovering and retrieving water data available from U.S. federal hydrologic web services},
publisher = {U.S. Geological Survey},
address = {Reston, VA},
version = {2.7.9},
institution = {U.S. Geological Survey},
year = {2021},
doi = {10.5066/P9X4L3GE},
url = {https://code.usgs.gov/water/dataRetrieval},
}
We could do something like:
df <- readNWISdv("05212700", "00060", "2021-01-01","2021-01-07")
cite_NWIS <- citation(df)
toBibtex(cite_NWIS)
@Manual{,
get the right NWIS citation worked out here...
}
Anyway, great idea, thanks again.
I didn't mean to close this...in fact I have a function coming out soon
So with the most recent updates you can now do this:
library(dataRetrieval)
WQPData <- readWQPqw("USGS-05288705",
parameterCd = "00300")
wqp_citation <- create_WQP_bib(WQPData)
wqp_citation
National Water Quality Monitoring Council (2024). _ Water
Quality Portal_. doi:10.5066/P9QRKUVJ
<https://doi.org/10.5066/P9QRKUVJ>, Accessed Feb 09, 2024,
<https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&pCode=00300&mimeType=tsv&zip=yes>.
print(wqp_citation, style = "Bibtex")
@Manual{,
title = { Water Quality Portal},
author = {{National Water Quality Monitoring Council}},
doi = {10.5066/P9QRKUVJ},
note = {Accessed Feb 09, 2024},
year = {2024},
url = {https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&pCode=00300&mimeType=tsv&zip=yes},
}
print(wqp_citation, style = "citation")
National Water Quality Monitoring Council, 2024, Water Quality
Portal, accessed 02, 09, 2024,
https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&pCode=00300&mimeType=tsv&zip=yes,
https://doi.org/10.5066/P9QRKUVJ.
A BibTeX entry for LaTeX users is
@Manual{,
title = { Water Quality Portal},
author = {{National Water Quality Monitoring Council}},
doi = {10.5066/P9QRKUVJ},
note = {Accessed Feb 09, 2024},
year = {2024},
url = {https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&pCode=00300&mimeType=tsv&zip=yes},
}
nwisData <- readNWISdv("04085427", "00060", "2012-01-01", "2012-06-30")
nwis_citation <- create_NWIS_bib(nwisData)
nwis_citation
U.S. Geological Survey (2024). _National Water Information
System data available on the World Wide Web (USGS Water Data
for the Nation)_. doi:10.5066/F7P55KJN
<https://doi.org/10.5066/F7P55KJN>, Accessed Feb 09, 2024,
<https://waterservices.usgs.gov/nwis/dv/?site=04085427&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2012-01-01&endDT=2012-06-30>.
print(nwis_citation, style = "Bibtex")
@Manual{,
title = {National Water Information System data available on the World Wide Web (USGS Water Data for the Nation)},
author = {{U.S. Geological Survey}},
doi = {10.5066/F7P55KJN},
note = {Accessed Feb 09, 2024},
year = {2024},
url = {https://waterservices.usgs.gov/nwis/dv/?site=04085427&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2012-01-01&endDT=2012-06-30},
}
print(nwis_citation, style = "citation")
U.S. Geological Survey, 2024, National Water Information System
data available on the World Wide Web (USGS Water Data for the
Nation), accessed Feb 09, 2024, at
https://waterservices.usgs.gov/nwis/dv/?site=04085427&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2012-01-01&endDT=2012-06-30,
http://dx.doi.org/10.5066/F7P55KJN
A BibTeX entry for LaTeX users is
@Manual{,
title = {National Water Information System data available on the World Wide Web (USGS Water Data for the Nation)},
author = {{U.S. Geological Survey}},
doi = {10.5066/F7P55KJN},
note = {Accessed Feb 09, 2024},
year = {2024},
url = {https://waterservices.usgs.gov/nwis/dv/?site=04085427&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2012-01-01&endDT=2012-06-30},
}
It would be useful to have a constructor function for creating NWIS bibliographic entries as per USGS publication series requirements. Potentially, expanding the functionality to other general bibliographic entry styles for other publishers and considering manual LaTeX style bibliographic entries as well as BibTeX entries. For this posting, only a USGS style is implemented as a basis for further consideration by the dataRetrieval developers. At least the support for USGS style, re-enforces the "policy" of reporting access dates and mandatory use of the DOI url to NWIS itself.
PS: A manual LaTeX entry in USGS style might look like this with the citation year being changed on the fly.
Code and documentation follow:
Here is proposed Rd content (sorry, I write long-hand Rds) and please note the use of some type of optional attributes to the string is very deliberate for also writing log files with at much low-level string work for a file name being done within the function. Suggest that some type of output file naming argument could be added to replace my hard wired NWISACCESS*.txt structure.