Using hydroscoper to get stations’ and time-series’ data

Konstantinos Vantas

2017-12-21

Introduction

This vignette shows how to create a tidy dataframe for the stations’ and time-series’ data from Hydroscope. The subdomain of Hydroscope that we will aplly the package’s functions is http:/kyy.hydroscope.gr

Get stations values

The following code, with the use of ldply function from plyr package, shows how to create a tidy dataframe with all the values of the stations, including their coordinates and elevation, from a subdomain.

library(hydroscoper)
library(plyr)

subdomain <- "kyy"

# get stations data
stations <- get_stations(subdomain)
 
# get coordinates and elevation
coords <- ldply(stations$StationID, function(id) {
   get_coords(subdomain, id)
})

# merge data
stations <- merge(stations, coords, by = "StationID", all.x = TRUE)

# show data
head(stations)

Get time-series values

The following code shows, with the use of ldply function from plyr package, how to create a tidy dataframe with all the time series from the subdomain.

# create timeseries dataframe
timeseries <- ldply(stations$StationID, function(id) {
  get_timeseries(subdomain, id)
})

head(timeseries)