Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (49 sloc) 2.06 KB
---
title: "How to Access OpenSky Network Data"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{How to Access OpenSky Network Data}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```r
library(trrrj)
```
The [OpenSky Network](https://opensky-network.org/) organization provides access to the
[historical data](https://opensky-network.org/data/impala)
stored in its database via a SQL-like query interface based on Cloudera's Impala.
The `trrrj` package provides R functions to access predefined datasets such as
[arrival](https://opensky-network.org/apidoc/rest.html#arrivals-by-airport)
and [departure](https://opensky-network.org/apidoc/rest.html#departures-by-airport) flights
(and relevant tracks) or
[state vectors](https://opensky-network.org/apidoc/index.html#state-vectors).
## Open a Session to OSN Impala
The first step to access OSN historical data is to set a connection up to the Impala shell.
The `connect_osn` function returns an SSH session to the OSN infrastructure which
has to be passed to all function when retrieving historical data.
We assume your credentials are store in the environment variables
`OSN_IMPALA_USR` for the user name and `OSN_IMPALA_PWD` for the password.
```r
session <- connect_osn(usr = Sys.getenv("OSN_IMPALA_USR"),
passwd = Sys.getenv("OSN_IMPALA_PWD"))
session
```
## Retrieve OSN Historical Data
you can now retrieve for example all departures from Frankfurt airport on 2019-04-22
between 10:00 and 12:00.
Note that this time interval is NOT the one for the scheduled flight departures, but rather
the interval within which OSN network has first seen those flights.
```r
wef <- "2019-04-22 10:00:00"
til <- "2019-04-22 12:00:00"
# ICAO ID for Frankfurt Airport
apt <- "EDDF"
dd <- departures_impala_osn(session, "EDDF", wef, til)
head(dd)
```
## Disconnect from OSN Impala
Once finished working it is good practice to disconnect from the OSN infrastructure
via the `disconnect_osn` function. This simply closes the underlying SSH session.
```r
disconnect_osn(session)
```
You can’t perform that action at this time.