add interactive map with leaflet
This commit is contained in:
@@ -60,7 +60,7 @@ ui <- fluidPage(
|
|||||||
|
|
||||||
tabPanel("Single Flight Analysis",
|
tabPanel("Single Flight Analysis",
|
||||||
fluidRow(
|
fluidRow(
|
||||||
column(6, plotOutput("route_plot", height = "400px")),
|
column(6, leafletOutput("route_plot", height = "400px")),
|
||||||
column(6, plotOutput("altitude_plot", height = "400px"))
|
column(6, plotOutput("altitude_plot", height = "400px"))
|
||||||
),
|
),
|
||||||
fluidRow(
|
fluidRow(
|
||||||
@@ -214,11 +214,9 @@ server <- function(input, output, session) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Route plot
|
# Route plot
|
||||||
output$route_plot <- renderPlot({
|
output$route_plot <- renderLeaflet({
|
||||||
req(rv$current_route)
|
req(rv$current_route)
|
||||||
plot(rv$current_route$lon, rv$current_route$lat, type = "o", pch = 20, col = "blue",
|
createInteractiveMap(rv$current_route)
|
||||||
main = paste("Geographic Route of", rv$current_icao),
|
|
||||||
xlab = "Longitude", ylab = "Latitude")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
# Altitude plot
|
# Altitude plot
|
||||||
|
|||||||
34
src/main.Rmd
34
src/main.Rmd
@@ -2,8 +2,8 @@
|
|||||||
title: "Topic 8 - Flight Trajectory Analysis"
|
title: "Topic 8 - Flight Trajectory Analysis"
|
||||||
subtitle: "Erik Neller, Patrik Mišura, Lukas Adrion"
|
subtitle: "Erik Neller, Patrik Mišura, Lukas Adrion"
|
||||||
output:
|
output:
|
||||||
pdf_document: default
|
|
||||||
html_document: default
|
html_document: default
|
||||||
|
pdf_document: default
|
||||||
date: "`r Sys.Date()`"
|
date: "`r Sys.Date()`"
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ library(httr)
|
|||||||
library(jsonlite)
|
library(jsonlite)
|
||||||
library(trajr)
|
library(trajr)
|
||||||
library(shiny)
|
library(shiny)
|
||||||
|
library(leaflet)
|
||||||
```
|
```
|
||||||
|
|
||||||
```{r opensky, include=FALSE}
|
```{r opensky, include=FALSE}
|
||||||
@@ -208,6 +209,27 @@ calculateStatsSummary <- function(trajectory_stats_df) {
|
|||||||
```{r viz-functions, include=FALSE}
|
```{r viz-functions, include=FALSE}
|
||||||
# Visualization Functions
|
# Visualization Functions
|
||||||
|
|
||||||
|
# Create interactive map with leaflet
|
||||||
|
createInteractiveMap <- function(route) {
|
||||||
|
leaflet(route) %>%
|
||||||
|
addTiles() %>%
|
||||||
|
addPolylines(lng=~lon, lat=~lat, color="blue", weight=3, opacity=0.8) %>%
|
||||||
|
addCircleMarkers(
|
||||||
|
lng = ~lon[1],
|
||||||
|
lat = ~lat[1],
|
||||||
|
color = "green",
|
||||||
|
radius = 6,
|
||||||
|
popup = "Origin"
|
||||||
|
) %>%
|
||||||
|
addCircleMarkers(
|
||||||
|
lng = ~lon[nrow(route)],
|
||||||
|
lat = ~lat[nrow(route)],
|
||||||
|
color = "red",
|
||||||
|
radius = 6,
|
||||||
|
popup = "Destination"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
# Create boxplots for trajectory statistics
|
# Create boxplots for trajectory statistics
|
||||||
createBoxplots <- function(trajectory_stats_df) {
|
createBoxplots <- function(trajectory_stats_df) {
|
||||||
p <- getTrajectoryParams()
|
p <- getTrajectoryParams()
|
||||||
@@ -417,17 +439,11 @@ if (is.null(route_df)) {
|
|||||||
|
|
||||||
## Step 4: Spatial Visualization
|
## Step 4: Spatial Visualization
|
||||||
|
|
||||||
The geographic trajectory is visualized in a Cartesian coordinate system. Green and red markers indicate departure and current/final position, respectively.
|
The geographic trajectory is visualized on an interactive map with leaflet using the `createInteractiveMap()` function. Green and red markers indicate departure and current/final position, respectively.
|
||||||
|
|
||||||
```{r demo-route-plot, fig.width=7, fig.height=5}
|
```{r demo-route-plot, fig.width=7, fig.height=5}
|
||||||
if (!is.null(route_df)) {
|
if (!is.null(route_df)) {
|
||||||
plot(route_df$lon, route_df$lat, type = "o", pch = 20, col = "blue",
|
createInteractiveMap(route_df)
|
||||||
main = paste("Flight Trajectory -", icao),
|
|
||||||
xlab = "Longitude (°)", ylab = "Latitude (°)")
|
|
||||||
points(route_df$lon[1], route_df$lat[1], pch = 17, col = "green", cex = 2)
|
|
||||||
points(route_df$lon[nrow(route_df)], route_df$lat[nrow(route_df)], pch = 15, col = "red", cex = 2)
|
|
||||||
legend("topright", legend = c("Origin", "Destination", "Trajectory"),
|
|
||||||
pch = c(17, 15, 20), col = c("green", "red", "blue"))
|
|
||||||
} else {
|
} else {
|
||||||
cat("Insufficient data for visualization\n")
|
cat("Insufficient data for visualization\n")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user