Git Product home page Git Product logo

hydat's Introduction

HYDAT

R package for reading from WSC HYDAT databases

Installation instructions

Dependencies

HYDAT depends on several other packages, which you need to install first, from CRAN, before installing HYDAT.

These packages are: reshape2, lubridate, DBI

In addition, you need to install the package RSQLite in order to actually use HYDAT.

Installing HYDAT

You can download the complete package, as well as the manual .pdf, by clicking on releases. However, you can download and install the most up-to-date version directly from this repository. The procedure is

  1. Install the package "devtools" - you only have to do this once. Note that this will also install several dependancies
  2. Load the devtools library
  3. Install the package.

The commands are:

install.packages("devtools")
library(devtools)
install_github("CentreForHydrology/HYDAT")

Using HYDAT

Downloading data

HYDAT uses SQLite databases of hydrological data from Environment Canada. You can get the most recent database from https://ec.gc.ca/rhc-wsc/default.asp?lang=En&n=9018B5EC-1. Be sure to download the file named "Hydat_sqlite3_YYYYMMDD.zip" where YYYMMDD is the date of the file. Once the file is downloaded, extract the SQLite database file Hydat.sqlite3.

Using the HYDAT R commands

Getting HYDAT data in R takes 3 steps:

  1. Connecting to the HYDAT database
  2. Retrieving the data
  3. Closing the connection.

Steps 1 and 3 require commands from the RSQLite package; step 2 requires a HYDAT command. This example extracts daily flow values for a given station.

HYDATfile <- 'Hydat.sqlite3'
WSCstation <- '05HG001'  # South Sask. River at Saskatoon
HYDAT <- dbConnect(SQLite(), HYDATfile)

dailyvals <- DailyHydrometricData(con = HYDAT, 
               get_flow = TRUE, 
               station_number = WSCstation)

dbDisconnect(HYDAT)

hydat's People

Contributors

davehutch avatar kevinshook avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.