USGS-R / drb-gw-hw-model-prep

Code repo to prepare groundwater and headwater-related datasets for modeling river temperature in the Delaware River Basin
Other
0 stars 3 forks source link

10 download monitoring sites sbtools #11

Closed msleckman closed 2 years ago

msleckman commented 2 years ago

Small PR.

In this PR, I've added try catch component to the download_sb_file() to address #10 .

Should ensure we can run grab unaggregated_temperature_observations_drb.zip and study_monitoring_sites.zip when commenting out code chunk 1_fetch.R#L: 43-52 and 1_fetch.R#L69-77

Note there is an on-going discussion on using facets url vs. a wfs operation for this automated download process. Worth discussing whether we prefer querying from sb facets url vs. a more generic (and lengthy) url. See comment download_sb_file.R#L23-L24

msleckman commented 2 years ago

Hm, good point @lekoenig. I am also seeing the error with item_file_download() , the same output as you, even though this error is being caught. Not sure how to not show it without wrapping the first expr in a surpresswarnings() like here:

{sbtools::item_file_download(sb_id = sb_id,
                                    names = file_name,
                                    destinations = out_path,
                                    overwrite_file = overwrite_file)}

For now, I simply added a bit more detail to the error message in this commit: https://github.com/USGS-R/drb-gw-hw-model-prep/pull/11/commits/60f413b68cc5043f93719e9aee37989b04a5d893

lekoenig commented 2 years ago

It seems like adding the curly braces around the expression in tryCatch might have done the trick?! Below is the output I see now when I try to download the study sites. Looks good, thanks! 🎉

> download_sb_file(sb_id = "623e54c4d34e915b67d83580",
+                  file_name = "study_monitoring_sites.zip",
+                  out_dir = "1_fetch/in")
Bypassing by downloading study_monitoring_sites.zip directly from: https://www.sciencebase.gov/catalogMaps/mapping/ows/623e54c4d34e915b67d83580?service=wfs&request=GetFeature&typeName=sb:study_monitoring_sites.zip&outputFormat=shape-zip&version=1.0.0
[1] "1_fetch/in/study_monitoring_sites.zip"
> 
msleckman commented 2 years ago

Worked for me too 🎉 . Merging and closing PR.