Learn R Programming

dataRetrieval (version 2.7.11)

readWQPdata: General Data Import from Water Quality Portal

Description

Imports data from Water Quality Portal web service. This function gets the data from here: https://www.waterqualitydata.us. because it allows for other agencies rather than the USGS.

Usage

readWQPdata(..., querySummary = FALSE, tz = "UTC", ignore_attributes = FALSE)

Arguments

see https://www.waterqualitydata.us/webservices_documentation for a complete list of options. A list of arguments can also be supplied.

querySummary

logical to ONLY return the number of records and unique sites that will be returned from this query. This argument is not supported via the combined list from the … argument

tz

character to set timezone attribute of dateTime. Default is "UTC", and converts the date times to UTC, properly accounting for daylight savings times based on the data's provided tz_cd column. Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", "America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". See also OlsonNames() for more information on time zones.

ignore_attributes

logical to choose to ignore fetching site and parameter attributes. Default is FALSE.

Value

A data frame with at least the following columns:

Name Type Description
OrganizationIdentifier character A designator used to uniquely identify a unique business establishment within a context.
OrganizationFormalName character The legal designator (i.e. formal name) of an organization.
ActivityIdentifier character Designator that uniquely identifies an activity within an organization.
ActivityTypeCode character The text describing the type of activity.
ActivityMediaName character Name or code indicating the environmental medium where the sample was taken.
ActivityMediaSubdivisionName character Name or code indicating the environmental matrix as a subdivision of the sample media.
ActivityStartDate character The calendar date on which the field activity is started.
ActivityStartTime.Time character The time of day that is reported when the field activity began, based on a 24-hour timescale.
ActivityStartTime.TimeZoneCode character The time zone for which the time of day is reported. Any of the longitudinal divisions of the earth's surface in which a standard time is kept.
ActivityEndDate character The calendar date when the field activity is completed.
ActivityEndTime.Time character The time of day that is reported when the field activity ended, based on a 24-hour timescale.
ActivityEndTime.TimeZoneCode character The time zone for which the time of day is reported. Any of the longitudinal divisions of the earth's surface in which a standard time is kept.
ActivityDepthHeightMeasure.MeasureValue character A measurement of the vertical location (measured from a reference point) at which an activity occurred. Measure value is given in the units stored in ActivityDepthHeightMeasure.MeasureUnitCode.
ActivityDepthHeightMeasure.MeasureUnitCode character The code that represents the unit for measuring the item.
ActivityDepthAltitudeReferencePointText character The reference used to indicate the datum or reference used to establish the depth/altitude of an activity.
ActivityTopDepthHeightMeasure.MeasureValue character A measurement of the upper vertical location of a vertical location range (measured from a reference point) at which an activity occurred. Measure value is given in the units stored in ActivityTopDepthHeightMeasure.MeasureUnitCode.
ActivityTopDepthHeightMeasure.MeasureUnitCode character The code that represents the unit for measuring the item.
ActivityBottomDepthHeightMeasure.MeasureValue character A measurement of the lower vertical location of a vertical location range (measured from a reference point) at which an activity occurred. Measure value is given in the units stored in ActivityBottomDepthHeightMeasure.MeasureUnitCode.
ActivityBottomDepthHeightMeasure.MeasureUnitCode character The code that represents the unit for measuring the item.
ProjectIdentifier character A designator used to uniquely identify a data collection project within a context of an organization.
ActivityConductingOrganizationText character A name of the Organization conducting an activity.
MonitoringLocationIdentifier character A designator used to describe the unique name, number, or code assigned to identify the monitoring location.
ActivityCommentText character General comments concerning the activity.
SampleAquifer * character A code that designates the aquifer associated with groundwater samples.
HydrologicCondition * character Hydrologic condition is the hydrologic condition that is represented by the sample collected (i.e. ? normal, falling, rising, peak stage).
HydrologicEvent * character A hydrologic event that is represented by the sample collected (i.e. - storm, drought, snowmelt).
SampleCollectionMethod.MethodIdentifier character The identification number or code assigned by the method publisher.
SampleCollectionMethod.MethodIdentifierContext character Identifies the source or data system that created or defined the identifier.
SampleCollectionMethod.MethodName character The title that appears on the method from the method publisher.
SampleCollectionEquipmentName character The name for the equipment used in collecting the sample.
ResultDetectionConditionText character The textual descriptor of a result.
CharacteristicName character The object, property, or substance which is evaluated or enumerated by either a direct field measurement, a direct field observation, or by laboratory analysis of material collected in the field.
ResultSampleFractionText character The text name of the portion of the sample associated with results obtained from a physically-partitioned sample.
ResultMeasureValue numeric The reportable measure of the result for the chemical, microbiological or other characteristic being analyzed. Measure value is given in the units stored in ResultMeasure.MeasureUnitCode.
MeasureQualifierCode character A code used to identify any qualifying issues that affect the results.
ResultMeasure.MeasureUnitCode character The code that represents the unit for measuring the item.
ResultStatusIdentifier character Indicates the acceptability of the result with respect to QA/QC criteria.
StatisticalBaseCode character The code for the method used to calculate derived results.
ResultValueTypeName character A name that qualifies the process which was used in the determination of the result value (e.g., actual, estimated, calculated).
ResultWeightBasisText character The name that represents the form of the sample or portion of the sample which is associated with the result value (e.g., wet weight, dry weight, ash-free dry weight).
ResultTimeBasisText character The period of time (in days) over which a measurement was made. For example, BOD can be measured as 5 day or 20 day BOD.
ResultTemperatureBasisText character The name that represents the controlled temperature at which the sample was maintained during analysis, e.g. 25 deg BOD analysis.
ResultParticleSizeBasisText character User defined free text describing the particle size class for which the associated result is defined.
PrecisionValue character A measure of mutual agreement among individual measurements of the same property usually under prescribed similar conditions.
ResultCommentText character Free text with general comments concerning the result.
USGSPCode * character 5-digit number used in the US Geological Survey computerized data system, National Water Information System (NWIS), to uniquely identify a specific constituent.
ResultDepthHeightMeasure.MeasureValue + character A measurement of the vertical location (measured from a reference point) at which a result occurred.
ResultDepthHeightMeasure.MeasureUnitCode + character The code that represents the unit for measuring the item.
ResultDepthAltitudeReferencePointText + character The reference used to indicate the datum or reference used to establish the depth/altitude of a result.
SubjectTaxonomicName character The name of the organism from which a tissue sample was taken.
SampleTissueAnatomyName * character The name of the anatomy from which a tissue sample was taken.
ResultAnalyticalMethod.MethodIdentifier character The identification number or code assigned by the method publisher.
ResultAnalyticalMethod.MethodIdentifierContext character Identifies the source or data system that created or defined the identifier.
ResultAnalyticalMethod.MethodName character The title that appears on the method from the method publisher.
MethodDescriptionText * character A brief summary that provides general information about the method.
LaboratoryName character The name of Lab responsible for the result.
AnalysisStartDate character The calendar date on which the analysis began.
ResultLaboratoryCommentText character Remarks which further describe the laboratory procedures which produced the result.
DetectionQuantitationLimitTypeName character Text describing the type of detection or quantitation level used in the analysis of a characteristic.
DetectionQuantitationLimitMeasure.MeasureValue numeric Constituent concentration that, when processed through the complete method, produces a signal that is statistically different from a blank. Measure value is given in the units stored in DetectionQuantitationLimitMeasure.MeasureUnitCode.
DetectionQuantitationLimitMeasure.MeasureUnitCode character The code that represents the unit for measuring the item.
PreparationStartDate character The calendar date when the preparation/extraction of the sample for analysis began.
ActivityStartDateTime POSIXct Activity start date and time converted to POSIXct UTC.
ActivityEndDateTime POSIXct Activity end date and time converted to POSIXct UTC.

* = elements only in NWIS + = elements only in STORET

There are also several useful attributes attached to the data frame:

Name Type Description
url character The url used to generate the data
siteInfo data.frame A data frame containing information on the requested sites
variableInfo data.frame A data frame containing information on the requested parameters
queryTime POSIXct The time the data was returned

Examples

Run this code
# NOT RUN {
nameToUse <- "pH"
pHData <- readWQPdata(siteid="USGS-04024315",characteristicName=nameToUse)
pHData_summary <- readWQPdata(bBox=c(-90.10,42.67,-88.64,43.35),
     characteristicName=nameToUse, querySummary=TRUE)
startDate <- as.Date("2013-01-01")
secchi.names = c("Depth, Secchi disk depth", 
                 "Depth, Secchi disk depth (choice list)", 
                 "Secchi Reading Condition (choice list)", 
                 "Water transparency, Secchi disc")
args <- list('startDateLo' = startDate, 
             'startDateHi' = "2013-12-31", 
              statecode="WI", 
              characteristicName=secchi.names)

wqp.data <- readWQPdata(args)   

args_2 <- list('startDateLo' = startDate, 
             'startDateHi' = "2013-12-31", 
              statecode="WI", 
              characteristicName=secchi.names,
              querySummary=TRUE)

wqp.summary <- readWQPdata(args_2) 

arg_3 <- list('startDateLo' = startDate, 
             'startDateHi' = "2013-12-31")
arg_4 <- list(statecode="WI", 
              characteristicName=secchi.names)
wqp.summary <- readWQPdata(arg_3, arg_4, querySummary=TRUE)
wqp.summary_WI <- readWQPdata(arg_3, statecode="WI", 
                              characteristicName=secchi.names, 
                              querySummary=TRUE)
                              
# querying by county
DeWitt <- readWQPdata(statecode = "Illinois", 
                      countycode= "DeWitt", 
                      characteristicName = "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")
# }

Run the code above in your browser using DataLab