21
Nov
2018
1

Tutorial – visualising data in Kepler with the RNLI

On 28 February 1823, Sir William Hillary made an impassioned appeal to the nation, calling for a service dedicated to saving lives at sea. That service was to become the Royal National Lifeboat Institution (RNLI).

Did you know?

  • There are 238 lifeboat stations around the coasts of Great Britain, Ireland, the Isle of Man and Channel Islands.
  • Tower Lifeboat Station on the River Thames in London is the RNLI’s busiest.
  • There are 349 lifeboats in the RNLI fleet.
  • The RNLI have 4,966 volunteers.
  • It cost £176.5m to run the RNLI in 2017.

Last week we looked at using QGIS to create some visualisations using data from the Royal National Lifeboat Institution (RNLI) and Ordnance Survey. This week we will be taking the same datasets and working with them within Kepler, Uber’s new open source geospatial analysis tool.

KEPLER (Pt 1)

Kepler is great for creating a range of different visualisations easily and quickly, and to begin with we are going to look at creating a visualisation depicting where in the UK most emergency call-outs are made. To do this we will need to download the RNLI Return of Service data.

For this tutorial we recommend using either Chrome or Safari as your web browser.

> Browse to this link https://kepler.gl/#/demo

> Drag the CSV called RNLI_Return_of_Service_20082016 into the map window or browse to the file.

By default, Kepler uses OpenStreetMap as its backdrop mapping but we can change this.

We recently announced details of the OS Open Zoomstack trial which gives users access to a comprehensive vector basemap showing coverage of Great Britain at a national level, right down to street level detail. This was made available in a number of formats and was so successful that we have now agreed to invest in making it a supported product.

This data can be served through Mapbox (an open source mapping platform for building custom designed maps) as vector tiles and this in turn can be read by Kepler. I have already created a map style using the OS Open Zoomstack vector tiles and this can be uploaded to your Mapbox account for use with this tutorial. If you do not have a Mapbox account, you will need to set one up and details on how to do this can be found here.

> Open Mapbox and click on Studio

> Click on Pick a template or upload a style

> Click on Upload

> The map style is called style.json and can be found here

JSON is short for JavaScript Object Notation and is a way to store information in an organised, easy-to-access manner. In a nutshell, it gives us a human-readable collection of data that we can access in a logical manner.

> Open the file. The map style should now be visible in your Mapbox window and is called OS Night-RNLI

> Next click on the back arrow next to your style header

> Click on the Menu button next to your style and click Make public

Setting public allows other users to copy this style into their account. Set it to private if you would rather this was not possible.

Now you have your map style loaded into Mapbox we can add it as a base map within Kepler.

> Keep Mapbox open and return to your Kepler window

> Click on Base Map which is the icon furthest right of the four at the top of the panel on the left-hand side

> Click on + Add Map Style

To fill out your Mapbox access token and style URL you will need to return to your Mapbox account.

> Add your Mapbox access token (found by clicking on account within your Mapbox userface)

> Your access token can be found here

(Use the clipboard option to copy your access token)

> Paste our style URL (found by clicking on menu next to our OS Night-RNLI style)

(Use the clipboard option to copy the URL)

> Name your style

> Click Add Style

Your new map data should now be visible within your Kepler map window.

> Click on the Layers icon (the icon furthest left)

Now we have the data loaded into Kepler and OS Open Zoomstack as our map backdrop, we can now start to visualise our RNLI data.

> Click on + Add Layer on the left-hand panel

> Rename your layer by clicking in your new layer box and editing the text (new layer)

> Under Layer Type select Hexbin

This will split the underlying topographical data into a grid made up of hexagons which we can size depending on our preferences. We can then style these depending on the amount of points from our CSV file that fall within these hexagons.

> Under Lat change this to the attribute Y

> Under Lng change this to the attribute X

This tells Kepler which fields it should use within the CSV to geo reference each of the points. Depending on your map backdrop, your data should now look something like this…

> Next, choose a sequential colour scale by clicking on the Colour ramp. Change Type to sequential and the number of steps within the ramp to 6

> Make sure your Colour Based On option is set to Point Count

> Give the hexagons a slight opacity by changing the Opacity value to 0.8

> Change the Radius of your hexagons to 1km and their Coverage to 0.78

So, we now have a 2D map depicting the location of RNLI call-outs based on a 1km hexagon grid. Each 1km hexagon has then been sequentially styled based on the amount of call out locations falling within that hexagon.

Let’s add a 3D element to our visualisation!

> Make sure Enable Height is active and change your Elevation Scale to 70

> Make sure your Height Based On is set to Point Count

Your hexagons should now be elevated based by the scale we set previously.

> Next, we to need change the plane of our map from a 2D to 3D map. Do this by clicking on the 3D Map icon on the right-hand side

Your map should now look similar to this, but depending on your map backdrop may be slightly different.

At this point you may find your map labels are being obscured by your overlain data.

At the beginning of this tutorial we looked at renaming our text description within Mapbox to include the suffix – labels. This is where that comes in handy.

> Click on Base Map

> For the Label map layer – click on Move to top of data layers

You should now have a map that looks similar to this.

The stand out insight from this dataset is just how busy the RNLI stations based around the River Thames are.

KEPLER (Pt 2)

Kepler can display lines drawn from one geo referenced point to another, so next we created a visualisation depicting the location of every RNLI lifeboat station and the location of their emergency call-outs through 2008-2016. This shows us just how busy some of these stations are and how far they must travel to aid in an emergency.

To do this we would have to join the two datasets together (RNLI Lifeboat Station Locations and RNLI Return of Service). One gives us our origin (lifeboat station) and the other gives us our destination (call-out). We can then tell Kepler to draw a line from one lat and long to another.

To join our two CSV’s we ran an SQL join within PostGIS and created a new CSV called RNLI_Flowlines.

> Load this CSV into Kepler

> Click on + Add Layer

> Set your Data Source to RNLI_Flowlines and your Layer Type to Line

> Fill out your layer’s settings as follows:

This map has been designed to focus in on individual stations so at this point, I suggest zooming in on a particular station to understand how the changes you are making to the layer’s settings are affecting the data.

Next, we are going to add a point to visualise the call-out location. This will help in interpreting the data easier.

> Load the RNLI_Return_of_Service_20082016 CSV into Kepler

> Click on + Add Layer

> Set your Data Source to RNLI_Return_of_Service_20082016 and your Layer Type to Point

> Fill out your layer’s settings as follows:

The visualisation is starting to take shape nicely, but I still think we can add a bit more clarity.

> Click on + Add Layer

> Set your Data Source to RNLI_Return_of_Service_20082016 again and your Layer Type to Point

> Fill out your layer’s settings as follows:

Next, we need to ensure our data layers are displaying in the correct order.

> Make sure each of your 3 layers are in this order. If they are not, drag each layer to its correct position by hovering your mouse curser to the left of each layer panel until 8 small dots appear and your curser changes. Left mouse click and hold and your layer panel should fade allowing you to move it to its correct position

Now let’s add a filter so we can concentrate our visualisation on an individual station.

> Click on Filters

> Click on + Add Filter

> Change your Data Source to RNLI_Flowlines.csv and your selected field to station. This is the field within our data’s attribution that we will be filtering on

The Values In box now allows us to select a station in which to focus our visualisation on.

> Change this to any station of interest within the data. I have chosen Brighton

This has filtered our data’s line layer, but we will need to do the same for our point layer.

> Click on + Add Filter

> Change your Data Source to RNLI_Return_of_Service_20082016.csv and your selected field to LifeboatStationNameProper (this attribute refers to RNLI stations but has a different header to our other CSV)

> Change the Values In box to the same station you filtered on for your lines

To save your Kepler workspace you will need to save out the Kepler configuration associated to your workspace.

> Click on Share

> Click on Export Config

> Make sure the Export Current Map check box is ticked

> Click Export and save your .json file

When planning on returning to your workspace you will need to reload this .json file back into Kepler in the same way you would load a data source.

You can also export these visuals as images.

> Click on Share

> Click on Export Image

> Change the settings within the Export Image window to suit your requirements and click download

Next week we will be looking at creating an interactive map using Tableau public.

You can download the latest version here.

You may also like

Tutorial – visualising data in Tableau with the RNLI
Tutorial – visualising data in QGIS with the RNLI
Meet the team: Joe Harrison
OS Open Zoomstack trial so far

1 Response

  1. Tim

    This is a great series of articles on the technical side of visualising data, but the really interesting thing here is that the RNLI release some of their data as ‘open data’ with a licence that allows its re-use. I really wish more organisations would do this and be more open with their data.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name* :

Email* :

Website: