Skip to content

Commit

Permalink
starting to implement SCAN and SNOTEL basic metadata, #61
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Mar 8, 2018
1 parent 7b11d5b commit 4461b75
Show file tree
Hide file tree
Showing 4 changed files with 1,130 additions and 0 deletions.
26 changes: 26 additions & 0 deletions R/fetchSCAN.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
## https://github.com/gunnarleffler/getSnotel
##

## site images:
## https://www.wcc.nrcs.usda.gov/siteimages/462.jpg
##
## site notes:
## https://wcc.sc.egov.usda.gov/nwcc/sitenotes?sitenum=462
##


## TODO: this crashes on 32bit R / libraries
# helper function for getting a single table of SCAN metadata
Expand Down Expand Up @@ -95,6 +102,22 @@ SCAN_sensor_metadata <- function(site.code) {
}


## implement this !
## https://github.com/ncss-tech/soilDB/issues/61
# site.code: vector of SCAN site codes
SCAN_site_metadata <- function(site.code) {

# hack to please R CMD check
SCAN_SNOTEL_metadata <- NULL

# cached copy available in soilDB::SCAN_SNOTEL_metadata
load(system.file("data/SCAN_SNOTEL_metadata.rda", package="soilDB")[1])

# finish this ...
}



# site.code: vector of site codes
# year: vector of years
# report: single report type
Expand Down Expand Up @@ -147,6 +170,9 @@ fetchSCAN <- function(site.code, year, report='SCAN', req=NULL) {
res.rows <- sum(sapply(res, nrow), na.rm=TRUE)
message(paste(res.rows, ' records (', res.size, ' Mb transferred)', sep=''))

## TODO combine site metadata into results
# m <- SCAN_site_metadata(site.code)

return(res)
}

Expand Down
Binary file added data/SCAN_SNOTEL_metadata.rda
Binary file not shown.
16 changes: 16 additions & 0 deletions misc/make-scan-snotel-metadata-db.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://github.com/ncss-tech/soilDB/issues/61

## get these data from SCAN www map, zoom all the way out and then click on export to CSV

x <- read.csv('scan-snotel-metadata.csv', stringsAsFactors = FALSE)

# fix HUC formatting
x$HUC <- as.character(as.numeric(x$HUC))

# check: OK
str(x)

# save as R data file
SCAN_SNOTEL_metadata <- x
save(SCAN_SNOTEL_metadata, file='../data/SCAN_SNOTEL_metadata.rda')

Loading

0 comments on commit 4461b75

Please sign in to comment.