Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dataRetrieval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water
dataRetrieval
Commits
07b2f10c
Commit
07b2f10c
authored
10 years ago
by
Laura A DeCicco
Browse files
Options
Downloads
Patches
Plain Diff
Adding common attributes.
parent
bb4c1bb1
No related branches found
No related tags found
1 merge request
!46
Adding attributes to WQP requests.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/importWQP.R
+34
-7
34 additions, 7 deletions
R/importWQP.R
with
34 additions
and
7 deletions
R/importWQP.R
+
34
−
7
View file @
07b2f10c
#' Basic Water Quality Portal Data
grabb
er
#' Basic Water Quality Portal Data
pars
er
#'
#'
#' Imports data from the Water Quality Portal based on a specified url.
#' Imports data from the Water Quality Portal based on a specified url.
#'
#'
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#' @return retval dataframe raw data returned from the Water Quality Portal. Additionally, a POSIXct dateTime column is supplied for
#' @return retval dataframe raw data returned from the Water Quality Portal. Additionally, a POSIXct dateTime column is supplied for
#' start and end times.
#' start and end times.
#' @export
#' @export
#' @seealso \code{\link{readWQPdata}}, \code{\link{readWQPqw}}, \code{\link{whatWQPsites}}
#' @import RCurl
#' @import RCurl
#' @import httr
#' @import httr
#' @import lubridate
#' @import lubridate
...
@@ -22,6 +23,8 @@
...
@@ -22,6 +23,8 @@
#' rawSample <- importWQP(rawSampleURL)
#' rawSample <- importWQP(rawSampleURL)
#' url2 <- paste0(rawSampleURL,"&zip=yes")
#' url2 <- paste0(rawSampleURL,"&zip=yes")
#' rawSample2 <- importWQP(url2, TRUE)
#' rawSample2 <- importWQP(url2, TRUE)
#' STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
#' STORETdata <- importWQP(STORETex)
#' }
#' }
importWQP
<-
function
(
url
,
zip
=
FALSE
,
tz
=
""
){
importWQP
<-
function
(
url
,
zip
=
FALSE
,
tz
=
""
){
...
@@ -109,15 +112,39 @@ importWQP <- function(url, zip=FALSE, tz=""){
...
@@ -109,15 +112,39 @@ importWQP <- function(url, zip=FALSE, tz=""){
}
}
if
(
any
(
!
is.na
(
timeZoneEnd
))){
if
(
any
(
!
is.na
(
timeZoneEnd
))){
retval
$
ActivityEndDateTime
<-
with
(
retval
,
as.POSIXct
(
paste
(
ActivityEndDate
,
ActivityEndTime.Time
),
format
=
"%Y-%m-%d %H:%M:%S"
,
tz
=
"UTC"
))
retval
$
ActivityEndDateTime
<-
with
(
retval
,
as.POSIXct
(
paste
(
ActivityEndDate
,
ActivityEndTime.Time
),
format
=
"%Y-%m-%d %H:%M:%S"
,
tz
=
"UTC"
))
retval
$
ActivityEndDateTime
<-
retval
$
ActivityEndDateTime
+
timeZoneEnd
*
60
*
60
retval
$
ActivityEndDateTime
<-
retval
$
ActivityEndDateTime
+
timeZoneEnd
*
60
*
60
retval
$
ActivityEndDateTime
<-
as.POSIXct
(
retval
$
ActivityEndDateTime
)
retval
$
ActivityEndDateTime
<-
as.POSIXct
(
retval
$
ActivityEndDateTime
)
}
if
(
all
(
is.na
(
retval
$
ActivityEndDateTime
))){
retval
$
ActivityEndDateTime
<-
NULL
}
}
siteInfo
<-
whatWQPsites
(
siteid
=
paste
(
unique
(
retval
$
MonitoringLocationIdentifier
),
collapse
=
","
))
siteInfoCommon
<-
data.frame
(
station_nm
=
siteInfo
$
MonitoringLocationName
,
agency_cd
=
siteInfo
$
OrganizationIdentifier
,
site_no
=
siteInfo
$
MonitoringLocationIdentifier
,
dec_lat_va
=
siteInfo
$
LatitudeMeasure
,
dec_lon_va
=
siteInfo
$
LongitudeMeasure
,
hucCd
=
siteInfo
$
HUCEightDigitCode
,
stringsAsFactors
=
FALSE
)
siteInfo
<-
cbind
(
siteInfoCommon
,
siteInfo
)
variableInfo
<-
data.frame
(
characteristicName
=
retval
$
CharacteristicName
,
parameterCd
=
retval
$
USGSPCode
,
param_units
=
retval
$
ResultMeasure.MeasureUnitCode
,
valueType
=
retval
$
ResultSampleFractionText
,
stringsAsFactors
=
FALSE
)
variableInfo
<-
unique
(
variableInfo
)
attr
(
retval
,
"siteInfo"
)
<-
siteInfo
attr
(
retval
,
"variableInfo"
)
<-
variableInfo
return
(
retval
)
return
(
retval
)
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment