Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Water
dataRetrieval
Commits
0c1d5011
Unverified
Commit
0c1d5011
authored
Feb 17, 2022
by
Laura A DeCicco
Committed by
GitHub
Feb 17, 2022
Browse files
Merge pull request #607 from ldecicco-USGS/main
dataProfile examples
parents
423204a4
68222758
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
.Rbuildignore
View file @
0c1d5011
...
...
@@ -50,3 +50,5 @@ vignettes/tutorial.Rmd
vignettes/phosData.rds
vignettes/waterservices.png
.gitlab-ci.yml
sample_large_pull.R
.github/workflows/R-CMD-check.yaml
View file @
0c1d5011
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on
:
push
:
branches
:
-
main
branches
:
main
pull_request
:
branches
:
-
main
branches
:
main
name
:
R-CMD-check
...
...
@@ -20,68 +20,30 @@ jobs:
config
:
-
{
os
:
macOS-latest
,
r
:
'
release'
}
-
{
os
:
windows-latest
,
r
:
'
release'
}
-
{
os
:
ubuntu-18.04
,
r
:
'
release'
,
rspm
:
"
https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"
}
-
{
os
:
ubuntu-latest
,
r
:
'
devel'
,
http-user-agent
:
'
release'
}
-
{
os
:
ubuntu-latest
,
r
:
'
release'
}
-
{
os
:
ubuntu-latest
,
r
:
'
oldrel-1'
}
env
:
R_REMOTES_NO_ERRORS_FROM_WARNINGS
:
true
RSPM
:
${{ matrix.config.rspm }}
GITHUB_PAT
:
${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE
:
yes
steps
:
-
uses
:
actions/checkout@v2
-
uses
:
r-lib/actions/setup-r@master
-
uses
:
r-lib/actions/setup-pandoc@v1
-
uses
:
r-lib/actions/setup-r@v1
with
:
r-version
:
${{ matrix.config.r }}
http-user-agent
:
${{ matrix.config.http-user-agent }}
use-public-rspm
:
true
-
uses
:
r-lib/actions/setup-pandoc@master
-
name
:
Query dependencies
run
:
|
install.packages(c('remotes', 'zoo', 'sf'))
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell
:
Rscript {0}
-
name
:
Cache R packages
if
:
runner.os != 'Windows'
uses
:
actions/cache@v1
-
uses
:
r-lib/actions/setup-r-dependencies@v1
with
:
path
:
${{ env.R_LIBS_USER }}
key
:
${{ runner.os }}-r-${{ matrix.config.r }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys
:
${{ runner.os }}-r-${{ matrix.config.r }}-1-
-
name
:
Install system dependencies
if
:
runner.os == 'Linux'
env
:
RHUB_PLATFORM
:
linux-x86_64-ubuntu-gcc
run
:
|
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
-
name
:
mac dependencies
if
:
runner.os == 'macOS'
run
:
brew install pkg-config gdal proj geos udunits
-
name
:
Install dependencies
run
:
|
remotes::install_deps(dependencies = TRUE)
install.packages(c('remotes', 'zoo', 'sf'))
remotes::install_cran("rcmdcheck")
shell
:
Rscript {0}
-
name
:
Session info
run
:
|
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell
:
Rscript {0}
extra-packages
:
rcmdcheck
-
name
:
Check
env
:
_R_CHECK_CRAN_INCOMING_
:
false
run
:
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell
:
Rscript {0}
-
uses
:
r-lib/actions/check-r-package@v1
-
name
:
Show testthat output
if
:
always()
...
...
@@ -90,7 +52,7 @@ jobs:
-
name
:
Upload check results
if
:
failure()
uses
:
actions/upload-artifact@ma
ster
uses
:
actions/upload-artifact@ma
in
with
:
name
:
${{ runner.os }}-r${{ matrix.config.r }}-results
path
:
check
path
:
check
\ No newline at end of file
DESCRIPTION
View file @
0c1d5011
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data
Version: 2.7.1
0.
1
Version: 2.7.11
Authors@R: c(
person("Laura", "DeCicco", role = c("aut","cre"),
email = "ldecicco@usgs.gov",
...
...
NEWS
View file @
0c1d5011
...
...
@@ -2,6 +2,8 @@ dataRetrieval 2.7.11
==================
* Updated some documentation to improve examples.
* Changed the check for internet to better account for proxies.
* Fixed bug due to new behavior in NWIS parameter code service.
* Updated documentation for readWQPdata and readWQPsummary
dataRetrieval 2.7.10
==================
...
...
R/importWQP.R
View file @
0c1d5011
...
...
@@ -157,43 +157,11 @@ importWQP <- function(obs_url, zip=TRUE, tz="UTC",
}
}
retval
<-
suppressWarnings
(
readr
::
read_delim
(
doc
,
col_types
=
readr
::
cols
(
`ActivityStartTime/Time`
=
readr
::
col_character
(),
`ActivityEndTime/Time`
=
readr
::
col_character
(),
USGSPCode
=
readr
::
col_character
(),
ResultCommentText
=
readr
::
col_character
(),
ResultSampleFractionText
=
readr
::
col_character
(),
ActivityDepthAltitudeReferencePointText
=
readr
::
col_character
(),
ActivityConductingOrganizationText
=
readr
::
col_character
(),
ActivityCommentText
=
readr
::
col_character
(),
ResultWeightBasisText
=
readr
::
col_character
(),
ResultTimeBasisText
=
readr
::
col_character
(),
ResultParticleSizeBasis
=
readr
::
col_character
(),
ResultDepthAltitudeReferencePointText
=
readr
::
col_character
(),
ResultLaboratoryCommentText
=
readr
::
col_character
(),
ResultTemperatureBasisText
=
readr
::
col_character
(),
ResultDetectionConditionText
=
readr
::
col_character
(),
ResultParticleSizeBasisText
=
readr
::
col_character
(),
`ActivityDepthHeightMeasure/MeasureValue`
=
readr
::
col_number
(),
`DetectionQuantitationLimitMeasure/MeasureValue`
=
readr
::
col_number
(),
ResultMeasureValue
=
readr
::
col_character
(),
`WellDepthMeasure/MeasureValue`
=
readr
::
col_number
(),
`WellHoleDepthMeasure/MeasureValue`
=
readr
::
col_number
(),
DetectionQuantitationLimitTypeName
=
readr
::
col_character
(),
LaboratoryName
=
readr
::
col_character
(),
MethodDescriptionText
=
readr
::
col_character
(),
`ResultAnalyticalMethod/MethodName`
=
readr
::
col_character
(),
`ResultAnalyticalMethod/MethodIdentifier`
=
readr
::
col_character
(),
`ResultAnalyticalMethod/MethodIdentifierContext`
=
readr
::
col_character
(),
SampleTissueAnatomyName
=
readr
::
col_character
(),
SubjectTaxonomicName
=
readr
::
col_character
(),
ResultDepthAltitudeReferencePointText
=
readr
::
col_character
(),
`ResultDepthHeightMeasure/MeasureUnitCode`
=
readr
::
col_character
(),
`DetectionQuantitationLimitMeasure/MeasureUnitCode`
=
readr
::
col_character
(),
`HUCEightDigitCode`
=
readr
::
col_character
(),
`ActivityEndTime/TimeZoneCode`
=
readr
::
col_character
()),
retval
<-
suppressWarnings
(
readr
::
read_delim
(
doc
,
col_types
=
readr
::
cols
(
.default
=
"c"
),
quote
=
ifelse
(
csv
,
'\"'
,
""
),
delim
=
ifelse
(
csv
,
","
,
"\t"
)))
delim
=
ifelse
(
csv
,
","
,
"\t"
),
guess_max
=
totalPossible
))
if
(
!
file.exists
(
obs_url
)){
actualNumReturned
<-
nrow
(
retval
)
...
...
@@ -202,18 +170,24 @@ importWQP <- function(obs_url, zip=TRUE, tz="UTC",
warning
(
"Number of rows returned not matched in header"
)
}
}
suppressWarnings
({
val
<-
tryCatch
(
as.numeric
(
retval
$
ResultMeasureValue
),
warning
=
function
(
w
)
w
)
valueCols
<-
names
(
retval
)[
grep
(
"MeasureValue"
,
names
(
retval
))]
countCols
<-
names
(
retval
)[
grep
(
"Count"
,
names
(
retval
))]
yearCols
<-
names
(
retval
)[
grep
(
"Year"
,
names
(
retval
))]
for
(
numberCol
in
unique
(
c
(
valueCols
,
countCols
,
yearCols
))){
suppressWarnings
({
val
<-
tryCatch
(
as.numeric
(
retval
[[
numberCol
]]),
warning
=
function
(
w
)
w
)
# we don't want to convert it to numeric if there are non-numeric chars
# If we leave it to the user, it will probably break a lot of code
if
(
!
"warning"
%in%
class
(
val
)){
retval
[[
numberCol
]]
<-
val
}
})
}
# we don't want to convert it to numeric if there are non-numeric chars
# they often happen after readr has decided the column type if we left it to readr
# If we leave it to the user, it will probably break a lot of code
# If we bump up readr's guess_max...the computational time becomes really really long
if
(
!
"warning"
%in%
class
(
val
)){
retval
$
ResultMeasureValue
<-
val
}
})
if
(
length
(
grep
(
"ActivityStartTime"
,
names
(
retval
)))
>
0
){
...
...
R/readNWISdata.r
View file @
0c1d5011
...
...
@@ -146,8 +146,10 @@ readNWISdata <- function(..., asDateTime=TRUE,convertType=TRUE,tz="UTC"){
if
(
any
(
service
%in%
c
(
"qw"
,
"qwdata"
))){
.Deprecated
(
old
=
"readNWISdata"
,
package
=
"dataRetrieval"
,
new
=
"readWQPdata"
,
msg
=
"NWIS qw web services are being retired. Please see the vignette
'Changes to NWIS QW services' for more information."
)
msg
=
"NWIS qw web services are being retired.
Please see vignette('qwdata_changes', package = 'dataRetrieval')
for more information.
https://cran.r-project.org/web/packages/dataRetrieval/vignettes/qwdata_changes.html"
)
}
values
<-
sapply
(
valuesList
$
values
,
function
(
x
)
URLencode
(
x
))
...
...
@@ -276,21 +278,22 @@ countyCdLookup <- function(state, county, outputType = "id"){
stop
(
"No county code provided"
)
}
if
(
length
(
state
)
>
1
){
stop
(
"Only one state allowed in countyCdLookup."
)
}
#first turn state into stateCd postal name
stateCd
<-
stateCdLookup
(
state
,
outputType
=
"postal"
)
state_counties
<-
countyCd
[
countyCd
$
STUSAB
==
stateCd
,]
if
(
is.numeric
(
county
)
|
!
is.na
(
suppressWarnings
(
as.numeric
(
county
)))){
county_i
<-
which
(
as.numeric
(
county
)
==
as.numeric
(
countyCd
$
COUNTY
)
&
stateCd
==
countyCd
$
STUSAB
)
}
else
{
# if no suffix was added, this will figure out what it should be (or throw a helpful error)
allSuffixes
<-
unique
(
tolower
(
unlist
(
lapply
(
strsplit
(
count
yCd
$
COUNTY_NAME
,
split
=
" "
),
tail
,
1
))
))
county_in_state
<-
grep
(
tolower
(
county
),
tolower
(
state_
count
ies
$
COUNTY_NAME
))
county_i
<-
unlist
(
lapply
(
allSuffixes
,
function
(
suffix
,
stateCd
,
county
){
currentSuffixExistsInString
<-
grepl
(
paste0
(
'(?i)\\'
,
suffix
,
'$'
),
tolower
(
county
))
retCounty
<-
ifelse
(
currentSuffixExistsInString
,
county
,
paste
(
county
,
suffix
))
retCounty_i
<-
which
(
tolower
(
retCounty
)
==
tolower
(
countyCd
$
COUNTY_NAME
)
&
stateCd
==
countyCd
$
STUSAB
)
return
(
retCounty_i
)
},
stateCd
,
county
))
county_i
<-
which
(
countyCd
$
STUSAB
==
stateCd
&
countyCd
$
COUNTY_NAME
==
state_counties
$
COUNTY_NAME
[
county_in_state
]
)
if
(
length
(
county_i
)
==
0
){
stop
(
paste
(
"Could not find"
,
county
,
"(county),"
,
stateCd
,
...
...
R/readNWISqw.r
View file @
0c1d5011
...
...
@@ -83,8 +83,10 @@ readNWISqw <- function (siteNumbers,parameterCd,startDate="",endDate="",
expanded
=
TRUE
,
reshape
=
FALSE
,
tz
=
"UTC"
){
.Deprecated
(
new
=
"readWQPqw"
,
package
=
"dataRetrieval"
,
msg
=
"NWIS qw web services are being retired. Please see the vignette
'Changes to NWIS QW services' for more information."
)
msg
=
"NWIS qw web services are being retired.
Please see vignette('qwdata_changes', package = 'dataRetrieval')
for more information.
https://cran.r-project.org/web/packages/dataRetrieval/vignettes/qwdata_changes.html"
)
pgrp
<-
c
(
"INF"
,
"PHY"
,
"INM"
,
"INN"
,
"NUT"
,
"MBI"
,
"BIO"
,
"IMM"
,
"IMN"
,
"TOX"
,
"OPE"
,
"OPC"
,
"OOT"
,
"RAD"
,
"XXX"
,
"SED"
,
"POP"
,
...
...
R/readWQPdata.R
View file @
0c1d5011
...
...
@@ -129,10 +129,54 @@
#' querySummary=TRUE)
#'
#' # querying by county
#'
dailyLexingtonVA
<- readWQPdata(statecode = "
Virginia
",
#'
countycode=
"Lexington
",
#'
p
ara
me
ter
Cd = "00010
")
#'
DeWitt
<- readWQPdata(statecode = "
Illinois
",
#' countycode=
"DeWitt
",
#'
ch
ara
c
ter
isticName = "Nitrogen
")
#'
#' # Data profiles: "Organization Data"
#' org_data <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' service = "Organization")
#'
#' # Data profiles: "Site Data Only"
#' site_data <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' service = "Station")
#'
#' # Data profiles: "Project Data"
#' project_data <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' service = "Project")
#'
#' # Data profiles: "Project Monitoring Location Weighting Data"
#' proj_mlwd <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' service = "ProjectMonitoringLocationWeighting")
#'
#' # Data profiles: "Sample Results (physical/chemical metadata)":
#' samp_data <- readWQPdata(siteid = "USGS-04024315",
#' dataProfile = "resultPhysChem")
#'
#' # Data profiles: "Sample Results (biological metadata)"
#' samp_bio <- readWQPdata(siteid="USGS-04024315",
#' dataProfile = "biological")
#'
#' # Data profiles: "Sample Results (narrow)"
#' samp_narrow <- readWQPdata(siteid="USGS-04024315",
#' dataProfile = "narrowResult")
#'
#' # Data profiles: "Sampling Activity"
#' samp_activity <- readWQPdata(siteid="USGS-04024315",
#' dataProfile = "activityAll")
#'
#' # Data profile: "Sampling Activity Metrics"
#' act_metrics <- readWQPdata(statecode = "WI",
#' countycode = "Dane",
#' service = "ActivityMetric")
#'
#' # Data profile: "Result Detection Quantitation Limit Data"
#' dl_data <- readWQPdata(siteid="USGS-04024315",
#' service = "ResultDetectionQuantitationLimit")
#' }
readWQPdata
<-
function
(
...
,
querySummary
=
FALSE
,
tz
=
"UTC"
,
ignore_attributes
=
FALSE
){
...
...
@@ -177,33 +221,24 @@ readWQPdata <- function(..., querySummary=FALSE, tz="UTC",
siteInfo
<-
cbind
(
siteInfoCommon
,
siteInfo
)
}
retvalVariableInfo
<-
retval
[,
c
(
"CharacteristicName"
,
"USGSPCode"
,
"ResultMeasure.MeasureUnitCode"
,
"ResultSampleFractionText"
)]
retvalVariableInfo
<-
unique
(
retvalVariableInfo
)
variableInfo
<-
data.frame
(
characteristicName
=
retval
$
CharacteristicName
,
parameterCd
=
retval
$
USGSPCode
,
param_units
=
retval
$
ResultMeasure.MeasureUnitCode
,
valueType
=
retval
$
ResultSampleFractionText
,
stringsAsFactors
=
FALSE
)
attr
(
retval
,
"siteInfo"
)
<-
siteInfo
if
(
!
anyNA
(
variableInfo
$
parameterCd
)){
pcodes
<-
unique
(
variableInfo
$
parameterCd
[
!
is.na
(
variableInfo
$
parameterCd
)])
pcodes
<-
pcodes
[
""
!=
pcodes
]
paramINFO
<-
readNWISpCode
(
pcodes
)
names
(
paramINFO
)[
"parameter_cd"
==
names
(
paramINFO
)]
<-
"parameterCd"
if
(
all
(
c
(
"CharacteristicName"
,
"ResultMeasure.MeasureUnitCode"
,
"ResultSampleFractionText"
)
%in%
names
(
retval
))){
retvalVariableInfo
<-
retval
[,
c
(
"CharacteristicName"
,
"ResultMeasure.MeasureUnitCode"
,
"ResultSampleFractionText"
)]
retvalVariableInfo
<-
unique
(
retvalVariableInfo
)
variableInfo
<-
data.frame
(
characteristicName
=
retval
$
CharacteristicName
,
param_units
=
retval
$
ResultMeasure.MeasureUnitCode
,
valueType
=
retval
$
ResultSampleFractionText
,
stringsAsFactors
=
FALSE
)
pCodeToName
<-
pCodeToName
varExtras
<-
pCodeToName
[
pCodeToName
$
parm_cd
%in%
unique
(
variableInfo
$
parameterCd
[
!
is.na
(
variableInfo
$
parameterCd
)]),]
names
(
varExtras
)[
names
(
varExtras
)
==
"parm_cd"
]
<-
"parameterCd"
variableInfo
<-
merge
(
variableInfo
,
varExtras
,
by
=
"parameterCd"
,
all
=
TRUE
)
variableInfo
<-
merge
(
variableInfo
,
paramINFO
,
by
=
"parameterCd"
,
all
=
TRUE
)
variableInfo
<-
unique
(
variableInfo
)
attr
(
retval
,
"variableInfo"
)
<-
variableInfo
}
attr
(
retval
,
"siteInfo"
)
<-
siteInfo
attr
(
retval
,
"variableInfo"
)
<-
variableInfo
}
else
{
if
(
!
ignore_attributes
){
message
(
"The following url returned no data:\n"
)
...
...
R/readWQPdots.R
View file @
0c1d5011
...
...
@@ -23,7 +23,20 @@ readWQPdots <- function(...){
service
<-
"Result"
}
match.arg
(
service
,
c
(
"Result"
,
"Station"
,
"Activity"
,
if
(
"dataProfile"
%in%
names
(
matchReturn
)){
profile
<-
matchReturn
$
dataProfile
if
(
profile
==
"activityAll"
){
service
<-
"Activity"
matchReturn
$
service
<-
NULL
}
else
if
(
profile
%in%
c
(
"resultPhysChem"
,
"biological"
,
"narrowResult"
)){
service
<-
"Result"
matchReturn
$
service
<-
NULL
}
}
match.arg
(
service
,
c
(
"Result"
,
"Station"
,
"Activity"
,
"Organization"
,
"ActivityMetric"
,
"SiteSummary"
,
"Project"
,
"ProjectMonitoringLocationWeighting"
,
"ResultDetectionQuantitationLimit"
,
"BiologicalMetric"
))
...
...
@@ -47,6 +60,10 @@ readWQPdots <- function(...){
names
(
values
)[
names
(
values
)
==
"countyCd"
]
<-
"countycode"
if
(
all
(
c
(
"countycode"
,
"statecode"
)
%in%
names
(
values
))){
stCd
<-
gsub
(
"US:"
,
""
,
values
[
"statecode"
])
# This will error if more than 1 state is requested
# It's possible that someone could requst more than one state
# in WQP, but if they also then request county codes,
# it gets really confusing, and the WQP developers don't recommend.
values
[
"countycode"
]
<-
paste
(
values
[
"statecode"
],
countyCdLookup
(
stCd
,
values
[
"countycode"
],
"id"
),
sep
=
":"
)
...
...
R/setAccess.R
View file @
0c1d5011
...
...
@@ -65,7 +65,8 @@ setAccess = function(access="public"){
pkg.env
$
ProjectMonitoringLocationWeighting
=
"https://www.waterqualitydata.us/data/ProjectMonitoringLocationWeighting/search"
pkg.env
$
ResultDetectionQuantitationLimit
=
"https://www.waterqualitydata.us/data/ResultDetectionQuantitationLimit/search"
pkg.env
$
BiologicalMetric
=
"https://www.waterqualitydata.us/data/BiologicalMetric/search"
pkg.env
$
Organization
=
"https://www.waterqualitydata.us/data/Organization/search"
pkg.env
$
NGWMN
=
"https://cida.usgs.gov/ngwmn_cache/sos"
}
...
...
R/sysdata.rda
View file @
0c1d5011
No preview for this file type
R/tabbedDataRetrievals.R
View file @
0c1d5011
...
...
@@ -86,8 +86,9 @@ NULL
#' US State Code Lookup Table
#'
#' Data pulled from \url{https://www2.census.gov/geo/docs/reference/state.txt}
#' on April 1, 2015.
#' Data originally pulled from \url{https://www2.census.gov/geo/docs/reference/state.txt}
#' on April 1, 2015. On Feb. 11, 2022, the fields were updated with the
#' file found in inst/extdata, which is used internally with NWIS retrievals.
#'
#' @name stateCd
#' @return stateCd data frame.
...
...
@@ -108,8 +109,9 @@ NULL
#' US County Code Lookup Table
#'
#' Data pulled from \url{https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
#' on April 1, 2015.
#' Data originally pulled from \url{https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
#' on April 1, 2015. On Feb. 11, 2022, the fields were updated with the
#' file found in inst/extdata, which is used internally with NWIS retrievals.
#'
#' @name countyCd
#' @return countyCd data frame.
...
...
@@ -127,4 +129,48 @@ NULL
#' @keywords USGS countyCd
#' @examples
#' head(countyCd)
NULL
\ No newline at end of file
NULL
# Here's how to incorporate the state_county.json into the historic
# sysdata.rda. The original data included some IDs that aren't in the json
# We're leaving those in for now because maybe it's helpful,
# even though to my knowledge it's not used in any dataRetrieval query.
# #Step 1: open the json file, parse out what's needed:
# x <- jsonlite::read_json("inst/extdata/state_county.json")
# states <- x[["US"]]
# state_df <- data.frame("STATE" = names(sapply(states$state_cd, function(x) x[[1]])),
# "STATE_NAME" = as.character(sapply(states$state_cd, function(x) x[[1]])))
# #Step 2: join it into the original stateCd data frame:
# # This preserves STATE_NAME, which is nice
#
# library(dplyr)
# state_df <- state_df %>%
# left_join(stateCd, by = c("STATE", "STATE_NAME"))
#
# state_df$STUSAB[state_df$STATE_NAME == "Virgin Islands"] <- "VI"
#
# #Step 3: now get the county names/ids:
# y <- sapply(states$state_cd, function(x) x[["county_cd"]])
#
# county_df <- data.frame()
#
# for(st in state_df$STATE){
# county_nums <- names(y[[st]])
# county_names <- as.character(unlist(y[[st]]))
# county_df_st <- data.frame(STATE = st,
# COUNTY = county_nums,
# COUNTY_NAME = county_names)
# county_df <- dplyr::bind_rows(county_df, county_df_st)
# }
#
# county_df_full <- county_df %>%
# left_join(select(state_df, STUSAB, STATE), by = "STATE") %>%
# left_join(select(countyCd, STATE, STUSAB, COUNTY, COUNTY_ID),
# by = c("STATE", "STUSAB", "COUNTY"))
#
# countyCd <- county_df_full
# stateCd <- state_df
# save(countyCd, stateCd, parameterCdFile, pCodeToName,
# file = "R/sysdata.rda", compress = "xz")
R/whatWQPsites.R
View file @
0c1d5011
...
...
@@ -143,22 +143,27 @@ whatWQPsites <- function(...){
#' @export
#' @examplesIf is_dataRetrieval_user()
#' \donttest{
#' # Summary of a single site for the last 5 years:
#' site_5 <- readWQPsummary(siteid="USGS-07144100",
#' summaryYears=5)
#'
#' # Summary of a single site for the full period of record:
#' site_all <- readWQPsummary(siteid="USGS-07144100",
#' summaryYears="all")
#'
#'
#' # Summary of the data available from streams in a single county:
#' dane_county_data <- readWQPsummary(countycode = "US:55:025",
#' summaryYears = 5,
#' siteType = "Stream")
#'
#'
#'
# Summary of the data all available from lakes in a single county:
#' lake_sites <- readWQPsummary(siteType = "Lake, Reservoir, Impoundment",
#' countycode = "US:55:025")
#'
#' # Very slow:
#' #state1 <- readWQPsummary(statecode="NJ")
#'
#' # Summary of the data available for the last 5 years in New Jersey:
#' state1 <- readWQPsummary(statecode="NJ",
#' summaryYears = 5,
#' siteType = "Stream")
#' }
readWQPsummary
<-
function
(
...
){
...
...
README.Rmd
View file @
0c1d5011
...
...
@@ -17,7 +17,7 @@ knitr::opts_chunk$set(
```
# dataRetrieval <img src="man/figures/logo.png" alt="dataRetrieval"
height="150px
" align="right" />
# dataRetrieval <img src="man/figures/logo.png" alt="dataRetrieval"
style="width:150px;height:auto;
" align="right" />
[](https://github.com/USGS-R/dataRetrieval/actions)[](https://coveralls.io/github/USGS-R/dataRetrieval?branch=main) [](https://owi.usgs.gov/R/packages.html#core) [](https://cran.r-project.org/package=dataRetrieval) [](https://cran.r-project.org/package=dataRetrieval) [](https://cran.r-project.org/package=dataRetrieval)
...
...
README.md
View file @
0c1d5011
# dataRetrieval <img src="man/figures/logo.png" alt="dataRetrieval"
height="150px
" align="right" />
# dataRetrieval <img src="man/figures/logo.png" alt="dataRetrieval"
style="width:150px;height:auto;
" align="right" />
Retrieval functions for USGS and EPA hydrologic and water quality data.
...
...
code.json
View file @
0c1d5011
...
...
@@ -3,7 +3,7 @@
"name"
:
"dataRetrieval"
,
"organization"
:
"U.S. Geological Survey"
,
"description"
:
"This R package is designed to obtain USGS or EPA water quality sample data, streamflow data, and metadata directly from web services"
,
"version"
:
"2.7.
9
"
,
"version"
:
"2.7.
11
"
,
"status"
:
"Production"
,
"permissions"
:
{
...
...
@@ -11,13 +11,13 @@
"licenses"
:
[
{
"name"
:
"Public Domain, CC0-1.0"
,
"URL"
:
"https://code.usgs.gov/
WMA-Data-Science
/dataRetrieval/blob/master/LICENSE.note"
"URL"
:
"https://code.usgs.gov/
water
/dataRetrieval/blob/master/LICENSE.note"
}
]
},
"homepageURL"
:
"https://code.usgs.gov/water/dataRetrieval"
,
"downloadURL"
:
"https://code.usgs.gov/water/dataRetrieval/-/archive/v2.7.
9
/dataRetrieval-v2.7.
9
.zip"
,
"downloadURL"
:
"https://code.usgs.gov/water/dataRetrieval/-/archive/v2.7.
11
/dataRetrieval-v2.7.
11
.zip"
,
"disclaimerURL"
:
"https://code.usgs.gov/water/dataRetrieval/blob/master/DISCLAIMER.md"
,
"repositoryURL"
:
"https://code.usgs.gov/water/dataRetrieval.git"
,
"vcs"
:
"git"
,
...
...
@@ -41,7 +41,7 @@
},
"date"
:
{
"metadataLastUpdated"
:
"202
1
-0
7-29
"
"metadataLastUpdated"
:
"202
2
-0
2-11
"
}
}
]
inst/extdata/state_county.json
0 → 100644
View file @
0c1d5011
This diff is collapsed.
Click to expand it.
man/countyCd.Rd
View file @
0c1d5011
...
...
@@ -17,8 +17,9 @@ COUNTY_ID \tab character \tab County id \cr
}
}
\description{
Data pulled from \url{https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
on April 1, 2015.
Data originally pulled from \url{https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt}
on April 1, 2015. On Feb. 11, 2022, the fields were updated with the
file found in inst/extdata, which is used internally with NWIS retrievals.
}
\examples{
head(countyCd)
...
...
man/readWQPdata.Rd
View file @
0c1d5011
...
...
@@ -142,10 +142,54 @@ wqp.summary_WI <- readWQPdata(arg_3, statecode="WI",
querySummary=TRUE)
# querying by county
dailyLexingtonVA
<- readWQPdata(statecode = "
Virginia
",
countycode=
"Lexington
",
p
ara
me
ter
Cd = "00010
")
DeWitt
<- readWQPdata(statecode = "
Illinois
",
countycode=
"DeWitt
",
ch
ara
c
ter
isticName = "Nitrogen
")