Skip to content

Commit

Permalink
SCAN/SNOTEL site metadata update #61
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Feb 26, 2021
1 parent 73c17b9 commit 41c9696
Show file tree
Hide file tree
Showing 3 changed files with 1,103 additions and 3 deletions.
Binary file modified data/SCAN_SNOTEL_metadata.rda
Binary file not shown.
14 changes: 11 additions & 3 deletions misc/make-scan-snotel-metadata-db.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
library(soilDB)
library(rvest)
library(xml)
library(plyr)

# https://github.com/ncss-tech/soilDB/issues/61

# attempt to cross-reference a lab ID via pedon ID
# using a LIMS report and HTML scraping, ick
# using a LIMS report and HTML scraping
# about 5 seconds per request
getLabPedon <- function(pedonID) {
url <- sprintf('https://nasis.sc.egov.usda.gov/NasisReportsWebSite/limsreport.aspx?report_name=Pedon+Description+html+(userpedid)&pedon_id=%s', pedonID)
Expand All @@ -25,9 +27,11 @@ getLabPedon <- Vectorize(getLabPedon)
## station list / site information
##

# 2021-02-25 DEB update site data from www map

# get these data from SCAN/SNOTEL www map, zoom all the way out and then click on export to CSV
# there are some trash data in here, trailing tabs
x <- read.csv('scan-snotel-data/station-metadata.csv', stringsAsFactors = FALSE, colClasses = 'character')
x <- read.csv('scan-snotel-data/scan-snotel-site-data.csv', stringsAsFactors = FALSE, colClasses = 'character')

# fix formatting
x$Name <- trimws(x$Name)
Expand Down Expand Up @@ -101,7 +105,7 @@ names(p.scan)[-1] <- paste0(names(p.scan)[-1], '-SCAN')


##
## merge metada from various sources, filling in the missing values with best available data
## merge metadata from various sources, filling in the missing values with best available data
##

# unique set of site IDs
Expand Down Expand Up @@ -140,3 +144,7 @@ SCAN_SNOTEL_metadata[idx, c('Site', 'Name', 'climstanm')]
# save as R data file
save(SCAN_SNOTEL_metadata, file='../data/SCAN_SNOTEL_metadata.rda')





Loading

0 comments on commit 41c9696

Please sign in to comment.