The article discusses visualizing bi-directional trade flow between countries using Python maps. It covers the process from finding coordinates of arrows to creating necessary dictionary objects, along with detailed code snippets. The author plans to demonstrate visualizing net trade flow in the second part of the series. The article provides a comprehensive guide for Python-based trade flow visualization.
“`html
Visualizing trade flow in Python maps — Part I: Bi-directional trade flow maps
The exchange of goods and services between countries is crucial for assessing economic prowess, security of supply, and the nature of international relationships. Visualizing trade flow between countries can provide valuable insights into imports, exports, and the overall economic landscape.
Finding Coordinates of Arrows
To represent trade relationships between countries, I aimed to use arrow coordinates to visualize the two-way trade flow. This involved creating a project in an application such as Google Earth, exporting a KML file, and extracting the coordinates with a converter.
Data
The input data consists of trade relationships between neighboring countries, with each country pair having four coordinate points representing the start and end points of the two arrows. This data will be used to display trade relationships in a Python map.
Code description
The trade flow maps were visualized using the matplotlib and cartopy packages. This involved importing required packages, reading the shape file, extracting information of required countries, plotting the required countries, and setting up colormap, adding arrow patches, and color bar.
Conclusion
The post demonstrated how trade flow between countries, including export and import relationships, can be visualized in a Python map using two arrows. The cartopy and matplotlib packages were used for this purpose.
“`