Compare commits
9 Commits
feature/do
...
2f88c321d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f88c321d1 | ||
|
|
c2700b16a2 | ||
|
|
27813426ff | ||
|
|
09783fd652 | ||
|
|
38a622a4cc | ||
|
|
b34213d8ec | ||
|
|
73b4a52dd0 | ||
|
|
526d1d06ed | ||
|
|
172f7f8c27 |
159
main.Rmd
159
main.Rmd
@@ -1,159 +0,0 @@
|
||||
---
|
||||
title: "Topic 8"
|
||||
output:
|
||||
pdf_document: default
|
||||
html_document: default
|
||||
date: "`r Sys.Date()`"
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
# Load Library
|
||||
```{r preamble, echo=FALSE}
|
||||
library(dplyr)
|
||||
library(lubridate)
|
||||
library(readr)
|
||||
library(utils)
|
||||
library(openSkies)
|
||||
library(dotenv)
|
||||
library(httr)
|
||||
library(jsonlite)
|
||||
```
|
||||
# Download flights
|
||||
```{r include=FALSE}
|
||||
#
|
||||
#time_now <- Sys.time()
|
||||
#time_one_hour_ago <- time_now - 3600
|
||||
#
|
||||
## get departures from frankfurt airport
|
||||
#flights <- getAirportDepartures(airport = "EDDF", startTime = time_one_hour_ago, endTime = time_now)
|
||||
#
|
||||
#print(paste("Found flights:", length(flights)))
|
||||
#head(flights)
|
||||
```
|
||||
|
||||
|
||||
```{r openskies, include=FALSE}
|
||||
load_dot_env()
|
||||
my_client_id <- Sys.getenv("OPENSKY_CLIENT_ID")
|
||||
my_client_secret <- Sys.getenv("OPENSKY_CLIENT_SECRET")
|
||||
|
||||
token_url <- "https://auth.opensky-network.org/auth/realms/opensky-network/protocol/openid-connect/token"
|
||||
|
||||
token_resp <- POST(
|
||||
token_url,
|
||||
body = list(
|
||||
grant_type = "client_credentials",
|
||||
client_id = my_client_id,
|
||||
client_secret = my_client_secret
|
||||
),
|
||||
encode = "form"
|
||||
)
|
||||
|
||||
if (status_code(token_resp) == 200) {
|
||||
my_token <- content(token_resp)$access_token
|
||||
message("Token successfully generated")
|
||||
} else {
|
||||
stop(paste("Error while collecting token:", content(token_resp, as = "text")))
|
||||
}
|
||||
|
||||
time_now <- as.numeric(Sys.time())
|
||||
time_one_hour_ago <- time_now - 3600
|
||||
|
||||
api_url <- paste0("https://opensky-network.org/api/flights/departure?airport=EDDF&begin=",
|
||||
round(time_one_hour_ago), "&end=", round(time_now))
|
||||
|
||||
data_resp <- GET(
|
||||
api_url,
|
||||
add_headers(Authorization = paste("Bearer", my_token))
|
||||
)
|
||||
|
||||
if (status_code(data_resp) == 200) {
|
||||
departures_df <- fromJSON(content(data_resp, as = "text", encoding = "UTF-8"))
|
||||
print(head(departures_df))
|
||||
} else {
|
||||
print(paste("API Error:", status_code(data_resp)))
|
||||
print(content(data_resp, as = "text"))
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
```{r last5}
|
||||
|
||||
icao24 <- "4bcdf9"
|
||||
|
||||
time_now <- as.numeric(Sys.time())
|
||||
time_then <- time_now - (1 * 24 * 60 * 60)
|
||||
|
||||
api_url_aircraft <- paste0("https://opensky-network.org/api/flights/aircraft?icao24=",
|
||||
icao24, "&begin=", round(time_then), "&end=", round(time_now))
|
||||
|
||||
aircraft_resp <- GET(
|
||||
api_url_aircraft,
|
||||
add_headers(Authorization = paste("Bearer", my_token))
|
||||
)
|
||||
|
||||
if (status_code(aircraft_resp) == 200) {
|
||||
all_flights <- fromJSON(content(aircraft_resp, as = "text", encoding = "UTF-8"))
|
||||
|
||||
if (length(all_flights) > 0) {
|
||||
all_flights <- all_flights[order(all_flights$firstSeen, decreasing = TRUE), ]
|
||||
|
||||
last_5_flights <- head(all_flights, 5)
|
||||
|
||||
last_5_flights$firstSeen <- as.POSIXct(last_5_flights$firstSeen, origin="1970-01-01")
|
||||
last_5_flights$lastSeen <- as.POSIXct(last_5_flights$lastSeen, origin="1970-01-01")
|
||||
|
||||
print(last_5_flights[, c("icao24", "firstSeen", "estDepartureAirport", "estArrivalAirport")])
|
||||
} else {
|
||||
print("No flights in this timespan for this airplane")
|
||||
}
|
||||
} else {
|
||||
print(paste("Error:", status_code(aircraft_resp)))
|
||||
}
|
||||
```
|
||||
|
||||
# Plot the flights
|
||||
|
||||
```{r route}
|
||||
target_icao <- all_flights$icao24[1]
|
||||
|
||||
target_time <- as.numeric(all_flights$firstSeen[1])
|
||||
|
||||
api_url_track <- paste0("https://opensky-network.org/api/tracks/all?icao24=",
|
||||
target_icao, "&time=", target_time)
|
||||
|
||||
track_resp <- GET(
|
||||
api_url_track,
|
||||
add_headers(Authorization = paste("Bearer", my_token))
|
||||
)
|
||||
|
||||
if (status_code(track_resp) == 200) {
|
||||
track_data <- fromJSON(content(track_resp, 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 from", target_icao),
|
||||
xlab="Longitude", ylab="Latitude")
|
||||
|
||||
plot(route_df$time, route_df$alt, type="l", col="red", lwd=2,
|
||||
main=paste("Altitude profile of", target_icao),
|
||||
xlab="Time (Unix)", ylab="Height (Meter)")
|
||||
|
||||
} else {
|
||||
print("No path points from api")
|
||||
}
|
||||
|
||||
} else {
|
||||
print(paste("Error while getting the route. Status:", status_code(track_resp)))
|
||||
print(content(track_resp, as = "text"))
|
||||
}
|
||||
```
|
||||
153
renv.lock
153
renv.lock
@@ -58,6 +58,42 @@
|
||||
"Maintainer": "Kirill Müller <kirill@cynkra.com>",
|
||||
"Repository": "https://packagemanager.posit.co/cran/latest"
|
||||
},
|
||||
"MASS": {
|
||||
"Package": "MASS",
|
||||
"Version": "7.3-65",
|
||||
"Source": "Repository",
|
||||
"Priority": "recommended",
|
||||
"Date": "2025-02-19",
|
||||
"Revision": "$Rev: 3681 $",
|
||||
"Depends": [
|
||||
"R (>= 4.4.0)",
|
||||
"grDevices",
|
||||
"graphics",
|
||||
"stats",
|
||||
"utils"
|
||||
],
|
||||
"Imports": [
|
||||
"methods"
|
||||
],
|
||||
"Suggests": [
|
||||
"lattice",
|
||||
"nlme",
|
||||
"nnet",
|
||||
"survival"
|
||||
],
|
||||
"Authors@R": "c(person(\"Brian\", \"Ripley\", role = c(\"aut\", \"cre\", \"cph\"), email = \"Brian.Ripley@R-project.org\"), person(\"Bill\", \"Venables\", role = c(\"aut\", \"cph\")), person(c(\"Douglas\", \"M.\"), \"Bates\", role = \"ctb\"), person(\"Kurt\", \"Hornik\", role = \"trl\", comment = \"partial port ca 1998\"), person(\"Albrecht\", \"Gebhardt\", role = \"trl\", comment = \"partial port ca 1998\"), person(\"David\", \"Firth\", role = \"ctb\", comment = \"support functions for polr\"))",
|
||||
"Description": "Functions and datasets to support Venables and Ripley, \"Modern Applied Statistics with S\" (4th edition, 2002).",
|
||||
"Title": "Support Functions and Datasets for Venables and Ripley's MASS",
|
||||
"LazyData": "yes",
|
||||
"ByteCompile": "yes",
|
||||
"License": "GPL-2 | GPL-3",
|
||||
"URL": "http://www.stats.ox.ac.uk/pub/MASS4/",
|
||||
"Contact": "<MASS@stats.ox.ac.uk>",
|
||||
"NeedsCompilation": "yes",
|
||||
"Author": "Brian Ripley [aut, cre, cph], Bill Venables [aut, cph], Douglas M. Bates [ctb], Kurt Hornik [trl] (partial port ca 1998), Albrecht Gebhardt [trl] (partial port ca 1998), David Firth [ctb] (support functions for polr)",
|
||||
"Maintainer": "Brian Ripley <Brian.Ripley@R-project.org>",
|
||||
"Repository": "CRAN"
|
||||
},
|
||||
"R6": {
|
||||
"Package": "R6",
|
||||
"Version": "2.6.1",
|
||||
@@ -1897,12 +1933,13 @@
|
||||
},
|
||||
"openSkies": {
|
||||
"Package": "openSkies",
|
||||
"Version": "1.2.2",
|
||||
"Source": "Repository",
|
||||
"Version": "1.2.1",
|
||||
"Source": "GitHub",
|
||||
"Type": "Package",
|
||||
"Title": "Retrieval, Analysis and Visualization of Air Traffic Data",
|
||||
"Date": "2025-08-20",
|
||||
"Authors@R": "c( person(\"Rafael\", \"Ayala\", email = \"rafaelayalahernandez@gmail.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-9332-4623\")), person(\"Daniel\", \"Ayala\", email = \"dayala1@us.es\", role = \"aut\", comment = c(ORCID = \"0000-0003-2095-1009\")), person(\"David\", \"Ruiz\", email = \"druiz@us.es\", role = \"aut\", comment = c(ORCID = \"0000-0003-4460-5493\")), person(\"Aleix\", \"Sellés\", role = \"aut\"), person(\"Lara\", \"Selles Vidal\", email = \"lara.selles@oist.jp\", role = \"aut\", comment = c(ORCID = \"0000-0003-2537-6824\")))",
|
||||
"Date": "2024-04-03",
|
||||
"Author": "Rafael Ayala, Daniel Ayala, David Ruiz, Aleix Sellés, Lara Sellés Vidal",
|
||||
"Maintainer": "Rafael Ayala <rafael.ayala@oist.jp>",
|
||||
"Description": "Provides functionalities and data structures to retrieve, analyze and visualize aviation data. It includes a client interface to the 'OpenSky' API <https://opensky-network.org>. It allows retrieval of flight information, as well as aircraft state vectors.",
|
||||
"Acknowledgements": "The development of this software is supported by the Spanish Ministry of Science and Innovation (grant code PID2019-105471RB-I00) and the Regional Government of Andalusia (grant code P18-RT-1060).",
|
||||
"License": "CC BY-NC 4.0",
|
||||
@@ -1928,6 +1965,7 @@
|
||||
"knitr",
|
||||
"BiocStyle",
|
||||
"RUnit",
|
||||
"BiocGenerics",
|
||||
"rmarkdown",
|
||||
"markdown"
|
||||
],
|
||||
@@ -1935,9 +1973,13 @@
|
||||
"BugReports": "https://github.com/Rafael-Ayala/openSkies/issues",
|
||||
"NeedsCompilation": "no",
|
||||
"Encoding": "UTF-8",
|
||||
"Repository": "https://packagemanager.posit.co/cran/latest",
|
||||
"Author": "Rafael Ayala [aut, cre] (ORCID: <https://orcid.org/0000-0002-9332-4623>), Daniel Ayala [aut] (ORCID: <https://orcid.org/0000-0003-2095-1009>), David Ruiz [aut] (ORCID: <https://orcid.org/0000-0003-4460-5493>), Aleix Sellés [aut], Lara Selles Vidal [aut] (ORCID: <https://orcid.org/0000-0003-2537-6824>)",
|
||||
"Maintainer": "Rafael Ayala <rafaelayalahernandez@gmail.com>"
|
||||
"Repository": "CRAN",
|
||||
"RemoteType": "github",
|
||||
"RemoteHost": "api.github.com",
|
||||
"RemoteUsername": "eneller",
|
||||
"RemoteRepo": "openSkies",
|
||||
"RemoteRef": "main",
|
||||
"RemoteSha": "ea794da413c3c2ef86f7ca73306e5da50682cd79"
|
||||
},
|
||||
"openssl": {
|
||||
"Package": "openssl",
|
||||
@@ -2053,6 +2095,30 @@
|
||||
"NeedsCompilation": "no",
|
||||
"Repository": "https://packagemanager.posit.co/cran/latest"
|
||||
},
|
||||
"plotrix": {
|
||||
"Package": "plotrix",
|
||||
"Version": "3.8-13",
|
||||
"Source": "Repository",
|
||||
"Title": "Various Plotting Functions",
|
||||
"Authors@R": "c( person(\"Jim\", \"Lemon\", role = \"aut\"), person(\"Ben\", \"Bolker\", role = \"ctb\"), person(\"Sander\", \"Oom\", role = \"ctb\"), person(\"Eduardo\", \"Klein\", role = \"ctb\"), person(\"Barry\", \"Rowlingson\", role = \"ctb\"), person(\"Hadley\", \"Wickham\", role = \"ctb\"), person(\"Anupam\", \"Tyagi\", role = \"ctb\"), person(\"Olivier\", \"Eterradossi\", role = \"ctb\"), person(\"Gabor\", \"Grothendieck\", role = \"ctb\"), person(\"Michael\", \"Toews\", role = \"ctb\"), person(\"John\", \"Kane\", role = \"ctb\"), person(\"Rolf\", \"Turner\", role = \"ctb\"), person(\"Carl\", \"Witthoft\", role = \"ctb\"), person(\"Julian\", \"Stander\", role = \"ctb\"), person(\"Thomas\", \"Petzoldt\", role = \"ctb\"), person(\"Remko\", \"Duursma\", role = \"ctb\"), person(\"Elisa\", \"Biancotto\", role = \"ctb\"), person(\"Ofir\", \"Levy\", role = \"ctb\"), person(\"Christophe\", \"Dutang\", role = \"ctb\"), person(\"Peter\", \"Solymos\", role = \"ctb\"), person(\"Robby\", \"Engelmann\", role = \"ctb\"), person(\"Michael\", \"Hecker\", role = \"ctb\"), person(\"Felix\", \"Steinbeck\", role = \"ctb\"), person(\"Hans\", \"Borchers\", role = \"ctb\"), person(\"Henrik\", \"Singmann\", role = \"ctb\"), person(\"Ted\", \"Toal\", role = \"ctb\"), person(\"Derek\", \"Ogle\", role = \"ctb\"), person(\"Darshan\", \"Baral\", role = \"ctb\"), person(\"Ulrike\", \"Groemping\", role = \"ctb\"), person(\"Bill\", \"Venables\", role = \"ctb\"), person(family = \"The CRAN Team\", role = \"ctb\"), person(\"Duncan\", \"Murdoch\", email = \"murdoch.duncan@gmail.com\", role = c(\"ctb\", \"cre\")))",
|
||||
"Imports": [
|
||||
"grDevices",
|
||||
"graphics",
|
||||
"stats",
|
||||
"utils"
|
||||
],
|
||||
"Description": "Lots of plots, various labeling, axis and color scaling functions. The author/maintainer died in September 2023.",
|
||||
"License": "GPL (>= 2)",
|
||||
"NeedsCompilation": "no",
|
||||
"Depends": [
|
||||
"R (>= 3.5.0)"
|
||||
],
|
||||
"Repository": "CRAN",
|
||||
"URL": "https://plotrix.github.io/plotrix/, https://github.com/plotrix/plotrix",
|
||||
"BugReports": "https://github.com/plotrix/plotrix/issues",
|
||||
"Author": "Jim Lemon [aut], Ben Bolker [ctb], Sander Oom [ctb], Eduardo Klein [ctb], Barry Rowlingson [ctb], Hadley Wickham [ctb], Anupam Tyagi [ctb], Olivier Eterradossi [ctb], Gabor Grothendieck [ctb], Michael Toews [ctb], John Kane [ctb], Rolf Turner [ctb], Carl Witthoft [ctb], Julian Stander [ctb], Thomas Petzoldt [ctb], Remko Duursma [ctb], Elisa Biancotto [ctb], Ofir Levy [ctb], Christophe Dutang [ctb], Peter Solymos [ctb], Robby Engelmann [ctb], Michael Hecker [ctb], Felix Steinbeck [ctb], Hans Borchers [ctb], Henrik Singmann [ctb], Ted Toal [ctb], Derek Ogle [ctb], Darshan Baral [ctb], Ulrike Groemping [ctb], Bill Venables [ctb], The CRAN Team [ctb], Duncan Murdoch [ctb, cre]",
|
||||
"Maintainer": "Duncan Murdoch <murdoch.duncan@gmail.com>"
|
||||
},
|
||||
"plyr": {
|
||||
"Package": "plyr",
|
||||
"Version": "1.8.9",
|
||||
@@ -2541,6 +2607,37 @@
|
||||
"Maintainer": "Thomas Lin Pedersen <thomas.pedersen@posit.co>",
|
||||
"Repository": "https://packagemanager.posit.co/cran/latest"
|
||||
},
|
||||
"signal": {
|
||||
"Package": "signal",
|
||||
"Version": "1.8-1",
|
||||
"Source": "Repository",
|
||||
"Title": "Signal Processing",
|
||||
"Date": "2024-06-13",
|
||||
"Authors@R": "c(person(\"Uwe\", \"Ligges\", role = c(\"aut\", \"cre\"), email=\"ligges@statistik.tu-dortmund.de\", comment = \"new maintainer\"), person(\"Tom\", \"Short\", role = \"aut\", email = \"tshort@eprisolutions.com\", comment=\"port to R\"), person(\"Paul\", \"Kienzle\", role = \"aut\", comment=\"majority of the original sources\"), person(\"Sarah\", \"Schnackenberg\", role = \"ctb\", comment=\"various test cases and bug fixes\"), person(\"David\", \"Billinghurst\", role = \"ctb\"), person(\"Hans-Werner\", \"Borchers\", role = \"ctb\"), person(\"Andre\", \"Carezia\", role = \"ctb\"), person(\"Pascal\", \"Dupuis\", role = \"ctb\"), person(\"John W.\", \"Eaton\", role = \"ctb\"), person(\"E.\", \"Farhi\", role = \"ctb\"), person(\"Kai\", \"Habel\", role = \"ctb\"), person(\"Kurt\", \"Hornik\", role = \"ctb\"), person(\"Sebastian\", \"Krey\", role = \"ctb\"), person(\"Bill\", \"Lash\", role = \"ctb\"), person(\"Friedrich\", \"Leisch\", role = \"ctb\"), person(\"Olaf\", \"Mersmann\", role = \"ctb\"), person(\"Paulo\", \"Neis\", role = \"ctb\"), person(\"Jaakko\", \"Ruohio\", role = \"ctb\"), person(\"Julius O.\", \"Smith III\", role = \"ctb\"), \t person(\"Doug\", \"Stewart\", role = \"ctb\"), person(\"Andreas\", \"Weingessel\", role = \"ctb\"))",
|
||||
"Depends": [
|
||||
"R (>= 3.5.0)"
|
||||
],
|
||||
"Imports": [
|
||||
"MASS",
|
||||
"graphics",
|
||||
"grDevices",
|
||||
"stats",
|
||||
"utils"
|
||||
],
|
||||
"Suggests": [
|
||||
"pracma"
|
||||
],
|
||||
"Enhances": [
|
||||
"matlab"
|
||||
],
|
||||
"Description": "A set of signal processing functions originally written for 'Matlab' and 'Octave'. Includes filter generation utilities, filtering functions, resampling routines, and visualization of filter models. It also includes interpolation functions.",
|
||||
"License": "GPL-2",
|
||||
"URL": "https://signal.R-forge.R-project.org",
|
||||
"NeedsCompilation": "yes",
|
||||
"Author": "Uwe Ligges [aut, cre] (new maintainer), Tom Short [aut] (port to R), Paul Kienzle [aut] (majority of the original sources), Sarah Schnackenberg [ctb] (various test cases and bug fixes), David Billinghurst [ctb], Hans-Werner Borchers [ctb], Andre Carezia [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], E. Farhi [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Sebastian Krey [ctb], Bill Lash [ctb], Friedrich Leisch [ctb], Olaf Mersmann [ctb], Paulo Neis [ctb], Jaakko Ruohio [ctb], Julius O. Smith III [ctb], Doug Stewart [ctb], Andreas Weingessel [ctb]",
|
||||
"Maintainer": "Uwe Ligges <ligges@statistik.tu-dortmund.de>",
|
||||
"Repository": "CRAN"
|
||||
},
|
||||
"ssh": {
|
||||
"Package": "ssh",
|
||||
"Version": "0.9.4",
|
||||
@@ -2912,6 +3009,48 @@
|
||||
"Maintainer": "Yihui Xie <xie@yihui.name>",
|
||||
"Repository": "https://packagemanager.posit.co/cran/latest"
|
||||
},
|
||||
"trajr": {
|
||||
"Package": "trajr",
|
||||
"Version": "1.5.1",
|
||||
"Source": "Repository",
|
||||
"Type": "Package",
|
||||
"Title": "Animal Trajectory Analysis",
|
||||
"Date": "2023-11-28",
|
||||
"Authors@R": "person(\"Jim\", \"McLean\", email = \"jim_mclean@optusnet.com.au\", role = c(\"aut\", \"cre\"))",
|
||||
"Description": "A toolbox to assist with statistical analysis of animal trajectories. It provides simple access to algorithms for calculating and assessing a variety of characteristics such as speed and acceleration, as well as multiple measures of straightness or tortuosity. Some support is provided for 3-dimensional trajectories. McLean & Skowron Volponi (2018) <doi:10.1111/eth.12739>.",
|
||||
"License": "MIT + file LICENSE",
|
||||
"URL": "https://github.com/JimMcL/trajr",
|
||||
"BugReports": "https://github.com/JimMcL/trajr/issues",
|
||||
"Encoding": "UTF-8",
|
||||
"Imports": [
|
||||
"signal",
|
||||
"utils",
|
||||
"stats",
|
||||
"graphics",
|
||||
"plotrix",
|
||||
"grDevices"
|
||||
],
|
||||
"RoxygenNote": "7.2.3",
|
||||
"Suggests": [
|
||||
"knitr",
|
||||
"rmarkdown",
|
||||
"testthat",
|
||||
"readr",
|
||||
"tcltk",
|
||||
"sp",
|
||||
"MASS",
|
||||
"covr"
|
||||
],
|
||||
"VignetteBuilder": "knitr",
|
||||
"BuildVignettes": "true",
|
||||
"NeedsCompilation": "no",
|
||||
"Author": "Jim McLean [aut, cre]",
|
||||
"Maintainer": "Jim McLean <jim_mclean@optusnet.com.au>",
|
||||
"Depends": [
|
||||
"R (>= 3.5.0)"
|
||||
],
|
||||
"Repository": "CRAN"
|
||||
},
|
||||
"tzdb": {
|
||||
"Package": "tzdb",
|
||||
"Version": "0.5.0",
|
||||
|
||||
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