---
title: "Using `hydroscoper`'s data"
author: "Konstantinos Vantas"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using hydroscoper's data}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
 
```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This vignette shows how to use the package's internal data sets.

## Load libraries

```{r load_library}
library(hydroscoper)
library(tibble)
library(ggplot2)
```

## Data sets

There are three data sets stored in the package. `stations` is comprised of the stations' id, name, longitude, latitude, etc.

```{r stations_data}
stations
```

`timeseries` of the time series' id, the corresponding station, variable type, time step etc.

```{r timeseries_data}
timeseries
```

`greece_borders` is a data-frame for use with the function `geom_polygon` from the `ggplot2` package.

## Stations location

`stations` and `greece_borders` can be used to create a map with all Hydroscope's stations. Unfortunately, there is a number of them that have erroneous coordinates (over the sea and far from Greece). Also, there are 120 stations with missing coordinates.

```{r all_stations}
ggplot() + 
  geom_polygon(data = greece_borders,
               aes(long, lat, group = group),
               fill = "grey",
               color = NA) +
  geom_point(data = stations,
             aes(x = longitude, y = latitude, color = subdomain)) +
  scale_color_manual(values=c("#E64B35FF", "#4DBBD5FF", "#00A087FF", 
                              "#3C5488FF"))+
  coord_fixed(ratio=1) +
  theme_bw()
```

## Stations with available time series 

The location of the stations with time series available to download are presented at the following map.

```{r stations_with_timeseries}
stations_ts <- subset(stations, station_id %in% timeseries$station_id &
                        subdomain %in% c("kyy", "ypaat"))


ggplot() + 
  geom_polygon(data = greece_borders,
               aes(long, lat, group = group),
               fill = "grey",
               color = NA) +
  geom_point(data = stations_ts,
             aes(x = longitude, y = latitude, color = subdomain)) +
  scale_color_manual(values=c("#00A087FF", "#3C5488FF"))+
  coord_fixed(ratio=1) +
  theme_bw()
```

Although there is a large number of stations with available data, there is heterogeneity in the coverage of the country.
