Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add HUC 22 for AS, GU, MP #23

Merged
merged 1 commit into from
Mar 15, 2022
Merged

Conversation

padilla410
Copy link
Contributor

In a surprising turn of events, it turns out that American Samoa, Guam, and the Northern Marianas do have a HUC code - it's "22". Our own documentation on this surprise is not consistent:

To dig into these inconsistencies a bit I have a snippet of code:

> library(dataRetrieval)
> library(dplyr)
> 
> us_terr <- c('AS', 'GU', 'MP')
> 
> # query by state code
> inv_stateCd <- lapply(us_terr, function(x){
+   whatNWISdata(stateCd = x, statCd = '00003', 
+                parameterCd = '00060', service = 'dv')
+ }) %>% 
+   bind_rows
>                                                                                                                                                                                           
> # query by HUC
> inv_huc <- whatNWISdata(huc = '22', statCd = '00003', 
+                         parameterCd = '00060', service = 'dv') %>% 
+   mutate(method = 'huc')
>                                                                                                                                                                                           
> # investigate stations not returned by both queries
> left_join(inv_stateCd, inv_huc) %>% 
+   filter(is.na(method)) %>% 
+   select(c(1:6, 7, 14, 22:25))
Joining, by = c("agency_cd", "site_no", "station_nm", "site_tp_cd", "dec_lat_va", "dec_long_va", "coord_acy_cd", "dec_coord_datum_cd", "alt_va", "alt_acy_va", "alt_datum_cd", "huc_cd", "data_type_cd", "parm_cd", "stat_cd", "ts_id", "loc_web_ds", "medium_grp_cd", "parm_grp_cd", "srs_id", "access_cd", "begin_date", "end_date", "count_nu")
  agency_cd         site_no                     station_nm site_tp_cd dec_lat_va dec_long_va coord_acy_cd parm_cd begin_date   end_date count_nu method
1      USGS 140733145105901 Matan Hanom Spring, Rota, CNMI         SP   14.12722    145.1855            S   00060 2000-06-08 2001-08-16      435   <NA>
2      USGS        16806000       Lupug Spring, Rota, CNMI         SP   14.12417    145.1894            S   00060 1902-07-17 1975-07-18     1413   <NA>

There are two sites that are missed when we query by HUC rather than stateCd, they have the following characteristics:

  • located in the Northern Marianas
  • Site Type == spring
  • Data is >= 20 years old

I would assume that we would probably miss some NWIS sites the CONUS + AK + HI + Caribbean regions if we did the same HUC vs stateCd comparison. I did not test this theory because creating the inventory for CONUS + AK + HI + Caribbean was running slowly for me (> 30 min). Because of this assumption, I have decided to keep the query method consistent for all regions.

I am tagging @limnoliver for this review because this is more of a overall "methods" PR rather than an in depth pipeline review.

Closes #19

@cnell-usgs
Copy link
Member

Wow so weird that there are different results with HUC vs stateCd. Nice sleuthing 🥇

@padilla410 padilla410 merged commit aa7fb6c into DOI-USGS:main Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include all U.S. territories
3 participants