Sunday, January 26, 2020

How to create your own World Sankey Maps

As the saying goes “A Sankey Diagram says more than 1000 pie charts”. Sankey Diagrams are very commonly used these days to visualize data flows for all sorts of data sets from personal budgets to job application results. But this type of visualization has a much more long and interesting history.

The term Sankey Diagram was first coined from Matthew Henry Phineas Riall Sankey’s 1898 illustration describing the energy efficiency of a steam engine. However, 30 years earlier another engineer Charles Joseph Minard had been using this same type of visualization to produce maps depicting numerical data flows.

This map produced by Minard charts the numbers and destinations of emigrants from Europe, Africa, China, and South Asia for the year 1858. Minard correlates the thickness of each line with the number of emigrants it represents, with one millimeter equaling 1,500 people.



The eloquence and ease of interpretation of this type of chart is clear. Minard received much recognition for the maps he produced. Modern information scientists say his 1869 map of Napoleon's Russian campaign may be the best statistical graphic ever drawn. Why don’t we see many examples of Sankey Maps today? There certainly are a few out there, and are often very impressive in the intuitive way they convey the data.

One reason they are not more common may be that they need to be crafted by hand using tools such as Adobe Illustrator. This is a time-consuming task requiring laborious attention to detail to ensure the visual representation matches the data. At MapProvision we have recognized the need for a way to produce Sankey Map easily and instantly. We have now added a new Sankey Map layer to show data flows between geographic locations. As with all MapProvision layers you can upload your own data and visualize it on a map within your own website, intranet, or stand alone webpage in five minutes, without needing to write any code.

Here's an example embedded Sankey Map Layer showing Japan's Fish Imports. Click the check box to start the animation.

You can mouse over the paths and nodes to drill down on the underlying data. You also can click the 'Full Screen' link to view this data set in its own tab.

+ Full Screen



You can view the full set of World Trade Organization Sankey Map data here.

The new Sankey Map visualization layer provides an easy way to understand data flows and volumes within a geographic context.

The width of each path is proportional to the volume of imports between the two countries.



Sankey Map Interactions


Users can mouse over the generated sankey paths and start/end points to see the underlying metrics that were used to generate the data layer on the map.

Hovering the mouse over a given path will show a tool tip displaying the size of the import from that country.


Hovering the mouse over a given start or end arrow at a node will show a tool tip with all the underlying metrics from or to that node. Doing this will also make all other node’s paths transparent so that the selected data is more prominent.


You can display multiple Sankey layers on the map at the same time and adjust the opacity of each layer on the fly. To do this click the selected layer in the layer tree, and use the opacity slider tool to drag the opacity up and down.

Symbolgy


The Sankey Map symbology can be be altered in either:
  • In the Viewer when viewing the layer where the symbology changes will stay in effect only until the layer tree is reloaded.
  • In the Manager when adding or updating the dataset. These changes will stay in effect indefinitely until the symbology is again updated.
In the Viewer you can temporarily change the Sankey Map layer symbology by right clicking the layer in the layer tree and selecting Symbology from the menu.

Or you can click the Symbology button while the layer is selected in the layer tree. Selection in the layer tree means the item in the tree has been clicked and is highlighted as opposed to having its checkbox ticked.



Color Bands


You can change the colors used to represent each path that is used to render the Sankey Map layer.

You can also select the color of the path when selected, the color of the source and target arrows, and the path thickness and opacity.

You can click the color square to popup a color picker as shown below to help choose your desired color.


Create your own Sankey Map


This blog post contains all the information you need to create your own interactive Sankey Maps on the web or within your own website or on your intranet.

You will first need to prepare your data file for upload. The Sankey data file format is different to the file format expected for other MapProvision layers as each data record requires a start and end point and the ability to craft custom descriptions for the tool tips when the user is interacting with the Sankey Map.

The basic Sankey data format is a Comma Separated Values (.csv) file shown in the format below. There is a source place name, a target place name, and a value for each Sankey path.



You can download the file used in this example by clicking here.

To display more information in the Sankey Map there are optional extra columns to add detailed descriptions to the Sankey Map when the user hovers over a Sankey Path or Start/End Point arrow.

The following example shows an example Sankey data format is a Comma Separated Values (.csv) file with detailed descriptions and units of measure added.



You can download the file used in this example by clicking here.

The Sankey Map uploader tool has a large number of place names such as countries and cities that it can recognize and automatically create the known coordinates on the map. Often you will want to use your own coordinates instead of a known place name so you can chart data to and from places that are more arbitrary and not recognized automatically by the uploader.

To use your own coordinates to specify source and target Sankey locations the following field names are also supported in your CSV files:
  • source_lat
  • source_lng
  • target_lat
  • target_lng

These can be used alongside plain English source and target names which are recognized by the application so that you have a balance between the convenience of automatic coordinate lookup for known places along with the ability to specify your own specific source and target locations when needed.

The following example shows an example Sankey Map data upload format where a mix of plain English place names are used along with specific coordinates specified for the Philippines:



You can download the file used in this example by clicking here.

Once you have your data upload file prepared launch the MapProvision Manager from the www.mapprovision.com website.



MapProvision uses Google Account user authentication to verify your identity If you do not have a Google account you can click sign up to create a Google account. 
 
After logging in you will be redirected to the MapProvision Manager. An account will be created for you containing an example Data Collection called 'MapProvision Examples' containing datasets and image layers that you can experiment with. 
 
Once your logged in to the Manager the next step is to create a new Data Collection to contain the data that you are going to upload. A Data Collection is set of data sets that has its own unique link that can be published to your website or viewed as a stand-alone web page. It also contains options for how you want the Map to appear such as location, zoom level and how the layers will be displayed in the layer tree presented to the user. 
 
To create a new data collection, open up the Manage Data Collections tree on the left and select: '*New Data Collection'. 
 

This will show a form asking for the name of your Data Collection. Give it a name and click Save. 
 


Click the 'Add Data Set' button. This will launch the add data set wizard. Enter the dataset name, description, and creator name. 



Then click the Layers tab to select the ‘Sankey’ layer. 



Optionally you can go the Symbology tab to change the symbology defaults to alter the colors and the way the Sankey Map is represented. 



Next click the Import Data tab. This is the tab you use to upload your data file.

Select File from the ‘Data Source’ drop down box. This will show the file upload tools. 



Click the Browse button to locate your CSV data file on your local hard drive. Select your upload file and click Open. This will start the file upload with the progress shown in the progress bar.

Once the file is uploaded and you are happy with the symbology you can click Save which will then store your newly created dataset into your own data collection.


Change the way the map is displayed


Optionally you may you may want to make changes to how the map will be presented for this Data Collection in the MapProvision Viewer. To do this click the Options button. This will launch the Options tool. Here you can adjust how the Data Collection’s map will be displayed in the viewer portal. 



Change the way the layer tree is arranged


Optionally you may want to configure how your layers will be arranged in the viewer's layer tree. To do this click the Organize Folders button. 

This will launch the Organize Folders tool. This will initially show the default Layer Tree's layout where layers are grouped into their respective layer types. Using the Organize Folders tool you can customize how the layers will appear to users in the Viewer. 

Expand the 'Sankey' folder to see your new data set in the layer tree. 


Then drag the new layer up to the top level of the layer tree. 




Then select all the folders and right click and select remove. 



Then click ‘Save’. Now your layer tree will just show the layer you have uploaded and not any superfluous folders. New data sets will be automatically appended at the end of your new tree layout as they are added.


Publish your Data Collection


That’s it! Now you can view your newly created Data Collection on the web, or embed it in your own website. Click the Publish button to launch the Publish tool. 

Here you can launch the Viewer containing your dataset by clicking the ‘Launch Viewer’ button. This will open the Viewer for your Data Collection on a new tab in your browser. 




You can embed the Data Collection's Viewer Portal in your website by pasting the HTML code provided by the tool into your web page as was done at the beginning of this blog entry.

To view more Import/Export Sankey Map Datasets, take a look at the full World Trade Organization demonstration data in its Viewer Portal here.



No comments:

Post a Comment