изменить тип карты в г - PullRequest
0 голосов
/ 04 марта 2019

Я тренируюсь на "листовке" и пытаюсь сменить эту карту на карту листовки.Данные и код от https://www.kaggle.com/jonathanbouchet/airlines-route-tracker/report

Мой токовый выход:

currentoutput

соответствующий код:

код для карты мира:

countries_map <- map_data("world")
world_map <- ggplot() + 
  geom_map(data = countries_map, 
           map = countries_map,
           aes(x = long, y = lat, map_id = region, group = group),
           fill = "light blue", color = "black", size = 0.1)

код для представления выходных данных на карте:

routes$num_aircraft <- sapply(routes$equipment, 
                              function(x) length(strsplit(x, " ")[[1]]))
routes_7_aircrafts <- routes %>% dplyr::filter(num_aircraft == 7)
routes_8_aircrafts <- routes %>% dplyr::filter(num_aircraft == 8)
routes_9_aircrafts <- routes %>% dplyr::filter(num_aircraft == 9)
routes_7 <- makeNetwork(routes_7_aircrafts, 'more than 6')
routes_8 <- makeNetwork(routes_8_aircrafts, 'more than 7')
routes_9 <- makeNetwork(routes_9_aircrafts, 'more than 8')
tot_routes <- rbind(routes_7, routes_8, routes_9)

world_map + 
  geom_curve(data = tot_routes, 
             aes(x = airport.start.long, y = airport.start.lat, xend = airport.end.long, 
                 yend = airport.end.lat, color = airline.name), 
             curvature = 0.2, arrow = arrow(length = unit(0.005, "npc")), 
             alpha = 1, size = 1.5) + 
  theme_fivethirtyeight() + 
  theme(
    legend.position = c(.85, 1.075),
    panel.grid.major = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    plot.title = element_text(face = "bold", hjust = .012, vjust = .8, 
                              colour = "#3C3C3C", size = 20),
    plot.subtitle = element_text(size = 10, hjust = 0, face = "italic", color = "black")) + 
  labs(
    title = "Busiest Routes in the World",
    subtitle = "Shown are the routes used by 7 or more different aircrafts") +
  scale_color_manual(name = "", values = c("Blue" ,"red" ,"green"))

Я пытаюсь создать тот же вывод, но с листовой картой, например так:

leaflet map-example

есть идеи?Спасибо!

...