Column
❈
Toby , a columnist for the Python Chinese community, currently works for the largest pharmaceutical big data platform in China, as the data analysis team leader. Focus on natural language processing, English cryptography, medical statistics.
Blog:
http://www.cnblogs.com/webRobot
❈ ——
——This article commemorates the 79th anniversary of the Nanjing Massacre
Today Toby teaches you how to use the python basemap package to draw a map of bombing Tokyo.
In the process of data visualization, we often need to display the data on a map based on the geographic location where it was collected. For example, we will want to draw cities, airplane routes, and even military bases on the map. Generally speaking, a geographic information system will have such a function. Today we discuss how to implement it on Python and use a free toolkit.
matplotlib is a data plotting package commonly used in Python. It is based on numpy's array operation function. Matplotlib has powerful drawing functions and can easily draw various statistical graphics, such as scatter plots, bar graphs, pie charts, etc. Matplotlib is often used in conjunction with numpy and scipy in many research fields. They are free tools, but their functions are sufficient to compete with Matlab, a major player in scientific research.
Basemap is a sub-package of Matplotlib, responsible for map drawing. In the process of data visualization, we often need to draw the data on the map. For example, we draw the urban population, aircraft routes, military bases, mineral deposits and so on on the map. Such geographic mapping helps readers understand spatially related information. Matplotlib official website: http://matplotlib.org/ Basemap official website: http://matplotlib.org/basemap/
By learning the basemap, we set Beijing as the missile launch base, and Japan's Tokyo, Hiroshima, Nagasaki, and Osaka as the attack targets. The missile launch trajectories are respectively four different color curves (red, yellow, green, and blue). The entire code of this script is as follows, with Chinese annotations added. Dear friends, you can practice it yourself. (This picture is a thumbnail)