It is a simple visualization of domestic airports and route information. The dot represents the location of 163 airports in China, and the line shows 5381 routes. I have seen on this website that the author used the r language to visualize route entries around the world. This figure is the result of imitating the shanzhai. However, the generation of this image is not as complex as that of the original image. The geographic chart package and steps used are slightly different from those in the original example. What fails to be compared is that the night view of the original image is not displayed. The specific implementation steps are as follows:
Download airport data and route data from this website;
Select and sort out Chinese airports and domestic routes;
Use the ggmap package to read Google Maps;
Map the airport and route information.
Library (ggmap)
Data. Port <-read.csv ( ' D: \ airports. dat ' , F)
Data. Line <-read.csv ( ' D: \ routes. dat ' , F)
Library (stringr)
# Find an airport in China
Portinchina <-str_detect (data. Port [, ' V4 ' ], " China ")
Chinaport <-Data. Port [portinchina,]
# Remove a few unnumbered airports
Chinaport <-chinaport [chinaport $ V5! = '' ,
C ( ' V3 ' , ' V5 ' , ' V7 ' , ' V8 ' , ' V9 ' )]
Names (chinaport) <-C ( ' City ' , ' Code ' , ' Lan ' , ' Lon ' , ' ATT ' )
# Find domestic flights
Lineinchina <-(data. Line [, ' V3 ' ] % In % chinaport $ code) & (data. Line [, ' V5 ' ] % In % chinaport $ code)
Chinaline <-Data. Line [lineinchina, C ( ' V3 ' , ' V5 ' , ' V9 ' )]
Names (chinaline) <-C ( ' Source ' , ' Destination ' , ' Equipment ' )
# Construct a function to obtain the latitude and longitude according to the airport code
Findposition <- Function (CODE ){
Find <-chinaport $ code = Code
X <-chinaport [find, ' Lon ' ]
Y <-chinaport [find, ' Lan ' ]
Return (data. Frame (x, y ))
}
# Convert airport code to latitude and longitude
From <-lapply (as. character (chinaline $ source), findposition)
From <-do. Call ( ' Rbind ' , From)
From $ group <- 1 : Dim (from )[ 1 ]
Names (from) <-C ( ' Lon ' , ' Lan ' , ' Group ' )
To <-lapply (as. character (chinaline $ destination), findposition)
To <-do. Call ( ' Rbind ' ,)
To $ group <- 1 : Dim ()[ 1 ]
Names (to) <-C ( ' Lon ' , ' Lan ' , ' Group ' )
Data. Line <-rbind (from,)
Temp <-Data. Line [data. Line $ group < 100 ,]
# Use the ggmap package to read map data from Google and mark the previous data on the map.
Ggmap (get_googlemap (center = ' China ' , Zoom = 4
T_quick bi
, <br>
Maptype = ' Roadmap ' ), Extent = ' Device ' ) +
Geom_point (Data = chinaport, AES (x = Lon, y = LAN ),
Color = ' Red4 ' , Alpha = 0.8 ) +
Geom_line (Data = data. Line, AES (x = Lon, y = LAN, group = group ),
Size = 0.1 , Alpha = 0.05 , Color = ' Red4 ' )
If you are interested, you can further study which route is the farthest, which is the most distributed, which route is the most, what is the Aircraft grade of the route, which airport is the highest altitude, and which airport is the busiest.
From: http://xccds1977.blogspot.com/2012/07/blog-post_26.html