Visualizing Global LPG Trade

Spencer James Stebbins
Posted on Aug 11, 2016

App: Beta Shiny Application  Github: Github


95% of the world's goods are transported via the ocean including a variety of cargo and essential energy resources. Liquid petroleum gas, commonly known as LPG or referred to as propane, is just one of these energy resources. LPG is mixture of flammable gases often used for heating, cooling appliances and cars in developing countries who lack the energy infrastructure for more common types of fuel. As these developing countries grow, the volume of LPG transported has followed to meet these developing countries increasing energy demands. The volume of LPG transported worldwide has increased drastically over the past 3 years and the order book for new vessels will account for 35% of all vessels on the water when completed by 2019. These trends substantiate the importance of this growing commodity type and this application was develop to better map global LPG transportation at a country and vessel level in order to assess the transformative patterns that have occurred over the past few years and dramatically visualize this data which has existed mainly in only private excel sheets. Furthermore, this project lays the foundation for a dashboard that could not only visualizes historical data as it does in its current state, but could merge this import/export data with automated production and ship position data to predict future over and undersupply of LPG in various regions (see next steps section for more) and give ship owners an edge positioning their open vessels in this increasingly competitive market. 


Probably the most noticeable trend in the last five years in global LPG transportation is the the dramatic change in which countries export the most LPG. The Far East region including primarily China, Japan, South Korea, and India have remained consistent as the largest importers of LPG year after year with an increase in Indian imports and a decrease in Japanese imports over the last few years. Although the volume of imported LPG has increased among these countries, the countries have remained fairly consistent. The same however cannot be said about countries which export LPG. Over the last five years, the greatest export countries of LPG have shifted dramatically. Five years ago, countries within the Arabian gulf region including Qatar, UAE, and Saudi Arabia dominated the global exports, while now the U.S. has become the single largest exporter of LPG (up from nearly zero exports in 2011). For those in the industry, this trend is common knowledge, but again this known trend has probably not been visualized in such a dramatic mapped fashion or through  flow charts that adjust dynamically over time. 

Screen Shot 2016-08-03 at 4.32.38 PM

Screen Shot 2016-08-03 at 4.32.54 PM

Next Steps

The real power of this application exists not in its current state, as a visualization dashboard, but through the potential it has if  further data sets are compared against this preexisting data. If I were to get access to APIs that automatically feed in the real time data for the pre-existing data sources, the current positions of all global VLGCs with their ballast or laden (empty or full) statuses worldwide, and LPG  inventory and production data at a country level, it would not be very difficult to assess present and future over or under supply of LPG globally. Comparing these data resources against the flow data the application already presents would allow a user to assess the number of VLGCs in each region or country compared to the inventories and production levels for that country both historically and forward looking. Predicting future over or under supply of VLGC and inventories has amazing potential because ship owners could then make more accurate speculations on where to send their open vessels. 


Technical Development

Data Manipulation

When starting this project, I knew I wanted to plot LPG trade data from IHS Connect (see Data section) which has lifting information indicating the volume traded as well as the source and destination countries of every voyage where a vessel was carrying LPG.  This was a great start, but the first hurdle was how to obtain coordinate data for countries in order to then plot the arcs between countries you see on the map tab. To do this, I merged this lifting data with the Google countries dataset (see Data section)  both on the source country and the destination country columns to assign a latitudinal and longitudinal center for each country.

Reactive Filtering

With this accomplished, I then created a reactive function to filter this lifting data based on user input from the date slider. This was done using observeEvents to update reactiveValues that could then be accessed within other reactive elements in the server.R file. The filterData reactive function filters the reactiveValue for data values$data based on the country dropdown selectors input$filter,which then updates the map, flow chart, and data table reactive components. However, because this filterData function doesn't change the reactiveValue, values$data, the list of all countries still within that date range is still accessible and can be used as the selection options in the dropdown country selector output$filter.

Threejs Globe

The most interesting part of developing this application from a technical standpoint was probably the implementation of the threejs package for R within a shiny dashboard application. The threejs package for R exposes a few threejs widgets including the globejs module which I used to create the main component for map tab of the application. Although threejs is a powerful javascript-based, graphics framework, this package really limits the amount of customization allowed on the exposed components. Given these limitations, I used the filterData function to update the arcs positioning, thickness, and colors based on adjustments to the reactive date slider.

Custom Styling

The rigidity of the adjusting Javascript and CSS from within a shiny R application was probably the most substantial hurdle I faced when developing this application. Although I was able to add script tags to the dashboard body to set up jQuery event handling, adjusting the threejs package from within the server.R was less successful given the time constraints of this project. Writing custom CSS was accomplished by injected a style tag at the top of the dashboard body component of the UI.R file like so:

For more information, read the inline comments within the files of the github repo

View Github: Github

Written in R, using R studio. Deployed using ShinyIO.

Packages used:

  • shiny
  • shinydashboard
  • DT
  • threejs
  • rgdal
  • dplyr
  • googleVis


About Author

Spencer James Stebbins

Spencer James Stebbins

Spencer Stebbins was the Lead Software Engineer at Dorian LPG; a NYSE listed company and the second largest LPG ship owner in the world. While at Dorian, Spencer was the project manager and lead engineer of DORIS; an...
View all posts by Spencer James Stebbins >

Leave a Comment

Rodrick March 25, 2017
Thanks for sharing these great tips Micheal, landing pages are really important in social media campaigns in order to maximize conversions as well as minimize the discrepancies

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp