Closed lekoenig closed 1 year ago
I did just notice that the actual data frame returned appears to be missing 6 of the columns that are contained in the siteInfo
field. So, we could grab siteInfo
from the new query instead:
station_data <- dataRetrieval::readWQPdata(
siteid = "USGS-04024315",
service = "Station"
)
siteInfo <- attr(station_data, 'siteInfo')
sum(!names(station_data) %in% names(siteInfo))
sum(!names(siteInfo) %in% names(station_data))
names(siteInfo)[!names(siteInfo) %in% names(station_data)]
[1] "station_nm" "agency_cd" "site_no" "dec_lat_va" "dec_lon_va" "hucCd"
Great point about scalability, @lindsayplatt. I considered that, but I don't think I fully considered the extent of i/o required to get the attributes at the national scale (for qs
and rds
files), or that this approach may not work for all file types. I think making a call to the "Station"
service is a good idea. And maybe we should set ignore_attributes = TRUE
in our actual WQP call if we do.
I did just notice that the actual data frame returned appears to be missing 6 of the columns that are contained in the siteInfo field
I think these are just repeated columns that get created within readWQPdata
(here), so we could even recreate those. I assume they're just meant to be more general column names and/or to match NWIS format.
I like the idea of using ignore_attributes = TRUE
in the WQP data call. It may cut down on some of the file sizes for those big pulls.
OK, in the latest commits I've reverted to calling the WQP "Station" service rather than trying to subset the attributes from the downloaded data frames. I agree that this approach is more robust for pipelines of varying scales.
Specific edits include:
fetch_wqp_data
function so that the user can choose to keep/ignore attributes, but by default, I ignore them since we now pull the site metadata separately.p2_wqp_site_ids_grouped
. p2_wqp_site_info
.
This PR grabs the
siteInfo
attribute from each branch ofp2_wqp_data_aoi
to create a new target calledp2_wqp_site_info
. The site metadata attribute does not get retained whenp2_wqp_data_aoi
is built by binding the individual branches, and so the new site info target contains a table that users can reference or join with the data table if they wish.As of the last time I built
p2_wqp_data_aoi
, we downloaded data from 552 sites within our example "watershed" and sop2_wqp_site_info
contains site metadata for 552 sites:@lindsayplatt, there's not a rush to merge this PR, I'm just trying to wrap up a couple lingering issues before some outreach that @padilla410 is planning for this spring. I'd suggest ~3 weeks turnaround, but let me know if you're swamped. This is the last set of code changes I'll make before releasing a new tag (see #103).
Closes #95