Compare commits
9 Commits
feature/do
...
2f88c321d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f88c321d1 | ||
|
|
c2700b16a2 | ||
|
|
27813426ff | ||
|
|
09783fd652 | ||
|
|
38a622a4cc | ||
|
|
b34213d8ec | ||
|
|
73b4a52dd0 | ||
|
|
526d1d06ed | ||
|
|
172f7f8c27 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -61,3 +61,5 @@ rsconnect/
|
||||
*.pdf
|
||||
*.html
|
||||
bib
|
||||
|
||||
.env
|
||||
|
||||
@@ -29,3 +29,5 @@ Use [renv](https://rstudio.github.io/renv/articles/renv.html) to install the cor
|
||||
``` r
|
||||
renv::restore()
|
||||
```
|
||||
|
||||
[OpenSky](https://opensky-network.org) access also requires credentials placed in a `.env` file, for which an example is provided in `.env.example`.
|
||||
|
||||
15
main.Rmd
15
main.Rmd
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: "Topic 8"
|
||||
output: html_document
|
||||
date: "`r Sys.Date()`"
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
# Download data
|
||||
from OpenSky https://opensky-network.org/datasets/states/#flights/
|
||||
```{r download}
|
||||
library(openSkies)
|
||||
```
|
||||
2
src/.env.example
Normal file
2
src/.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
OPENSKY_CLIENT_ID=changeme
|
||||
OPENSKY_CLIENT_SECRET=changeme
|
||||
94
src/main.Rmd
Normal file
94
src/main.Rmd
Normal file
@@ -0,0 +1,94 @@
|
||||
---
|
||||
title: "Topic 8"
|
||||
output:
|
||||
pdf_document: default
|
||||
html_document: default
|
||||
date: "`r Sys.Date()`"
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
```{r preamble, message=FALSE}
|
||||
# Load Libraries
|
||||
library(dplyr)
|
||||
library(lubridate)
|
||||
library(readr)
|
||||
library(utils)
|
||||
library(openSkies)
|
||||
library(dotenv)
|
||||
library(httr)
|
||||
library(jsonlite)
|
||||
library(trajr)
|
||||
```
|
||||
|
||||
# Download flights
|
||||
```{r opensky}
|
||||
|
||||
time_now <- Sys.time()
|
||||
creds <- getCredentials(
|
||||
client_id = Sys.getenv('OPENSKY_CLIENT_ID'),
|
||||
client_secret = Sys.getenv('OPENSKY_CLIENT_SECRET'))
|
||||
|
||||
# get departures from Frankfurt airport
|
||||
departures <- getAirportDepartures(airport = "EDDF", startTime = time_now - hours(1), endTime = time_now, credentials = creds )
|
||||
|
||||
getFlights <- function(icao, time, creds){
|
||||
flights <-getAircraftFlights(icao, startTime = time - days(1), endTime = time, credentials = creds )
|
||||
return(flights)
|
||||
}
|
||||
icao <- departures[[1]][["ICAO24"]]
|
||||
flights <- getFlights(icao,Sys.time(), creds)
|
||||
# TODO map from all available flights to tracks
|
||||
query <- list(icao24= icao, time=as.numeric(flights[[1]][["departure_time"]]))
|
||||
|
||||
# can get tracks for up to 30 days in the past
|
||||
response <-makeAuthenticatedRequest('tracks/all',query, creds)
|
||||
track_data <- fromJSON(content(response, as = "text", encoding = "UTF-8"))
|
||||
if (!is.null(track_data$path) && length(track_data$path) > 0) {
|
||||
|
||||
route_df <- as.data.frame(track_data$path)
|
||||
colnames(route_df) <- c("time", "lat", "lon", "alt", "heading", "on_ground")
|
||||
|
||||
message("Loading of route successfull! Points: ", nrow(route_df))
|
||||
|
||||
plot(route_df$lon, route_df$lat, type="o", pch=20, col="blue",
|
||||
main=paste("Geographic route of", icao),
|
||||
xlab="Longitude", ylab="Latitude")
|
||||
|
||||
plot(route_df$time, route_df$alt, type="l", col="red", lwd=2,
|
||||
main=paste("Altitude profile of", icao),
|
||||
xlab="Time (Unix)", ylab="Height (Meter)")
|
||||
|
||||
} else {
|
||||
print("No path points from api")
|
||||
}
|
||||
```
|
||||
|
||||
# GUI selection
|
||||
```{r gui}
|
||||
icaos <- lapply(departures, function(x) x[["ICAO24"]])
|
||||
options <- unlist(icaos) # tcltk needs a character vector
|
||||
|
||||
# Create a GUI list selection
|
||||
listSelect <- function(options){
|
||||
selected_option <- NULL
|
||||
tryCatch({
|
||||
selected_option <- select.list(
|
||||
title = "Select an aircraft",
|
||||
choices = options,
|
||||
preselect = NULL,
|
||||
multiple = FALSE,
|
||||
graphics = TRUE
|
||||
)
|
||||
}, error = function(w) {
|
||||
message('No GUI available')
|
||||
}
|
||||
)
|
||||
if (nzchar(selected_option)){
|
||||
return(selected_option)
|
||||
}
|
||||
return(options[1])
|
||||
}
|
||||
```
|
||||
33
src/slides.Rmd
Normal file
33
src/slides.Rmd
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: "Topic 8"
|
||||
date: "`r Sys.Date()`"
|
||||
output: beamer_presentation
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = FALSE)
|
||||
# {cat, child="../README.md"}
|
||||
```
|
||||
|
||||
## Task
|
||||
Develop an R-based software, which will perform the following tasks:
|
||||
|
||||
1. download from the OpenSky Network online database the observations of the trajectory of a randomly selected aircraft on a randomly selected flight over at least five days, in uninterrupted continuity (1)
|
||||
|
||||
2. perform the selections in the graphical user interface (GUI) of your R script,
|
||||
|
||||
3. determine the characteristics of each trajectory according to the parameters: diffusion distance, straightness, duration of travel, mean travel velocity and fractal dimension (2),
|
||||
|
||||
4. using the R library trajr, (4) perform basic statistical analysis of the parameters of daily trajectories from (3): arithmetic mean, variance, quartiles, boxplot, estimate of the density function of the experimental statistical distribution, analyze and interpret them.
|
||||
|
||||
|
||||
## Methodology
|
||||
|
||||
1. acquire data using the OpenSky API
|
||||
|
||||
2. use
|
||||
|
||||
## Contribution
|
||||
|
||||
- extended functionality of the `openSkies` R package and created a merge request
|
||||
|
||||
Reference in New Issue
Block a user