Hexbin Maps: Oh Rats! Workout Wednesday (#WoW) 2022 Challenge 16

After making a hexbin map last Friday for the last day of Dashboard Week, I’ve been itching to make another one. What better way to learn how to better make a hexbin map than by attempting a Workout Wednesday?

Last week's Dashboard: https://www.thedataschool.co.uk/jessica-kwan/dashboard-week-day-4-gift-travels-as-documented-by-congress-and-staff/

For this blog, I will be covering how I tackled #WOW2022 Challenge 16: Can you make a hexbin map? by Sean Miller (@HipsterVizNinja).

Requirements include:

  • Dashboard Size: generic desktop
  • Create a hexbin map of rat sightings
  • Create a bar chart showing total sightings by borough
  • Add interactivity to highlight the map

As stated in the Workout Wednesday, you can download the Rat Sightings dataset used in this challenge here. You can also download the hexagon for the hexbins here. Once you have everything downloaded, let’s get started!

First we need to make the Hexbin Longitude and the Hexbin Latitude:

Once Hexbinx and Hexbiny are created, right click on the individual fields and convert the fields to dimension fields.

This is what the fields look like after we create them.

Right click one of the fields and select Convert to Dimension


This is what it looks like after:


In order to use them to build a map, we will need to change the data type of the two fields. To do this:

1. Right click on Hexbin Longitude

2. Go to “Geographic Role”

3. Select “Longitude”

4. Repeat for Hexbin Latitude


This is how it should look after you’ve completed the steps above:

If we put the Hexbin Latitude field onto the rows shelf and the Hexbin Longitude field in the columns shelf, this is what appears in our view:

The Tableau Hexbin functions (Hexbinx, Hexbiny) take the x and y coordinates and bins everything hexagons where the hexagons have sides of exactly one unit. To make a hexmap, we will need to specify how many individual plots we want the x,y coordinates to be grouped in.

Before we dive into that, let’s change the shape of our mark from a circle to a hexagon.

  • Note: The hexagonal shape needs to be added into the Tableau Repository as it is not one of the default shapes that Tableau comes with.
  • I grabbed the shape from the link in the challenge: https://www.pngwing.com/en/free-png-bvqxl
  • For detailed instructions on how to add shapes to Tableau, check out the blog here!

Ok, back to the scale I mentioned above. To make it so that the user who uses the dashboard can select the number of hexagonal bins, I am using a parameter.

After creating the parameter, I had to go back to the Hexbin Longitude field and the Hexbin Latitude field and make the following changes:

Note: I am multiplying the longitude and latitude by the scale factor but also dividing the entire thing again by the scale factor so that we can make sure the values don’t actually change even though we can now see the individual hexbins.

Right click the parameter and select “Show Parameter”.

I set the value at 200 because the 250 that I had it set to at default made everything too crowded.

In this view, there are 200 points in each hexbin and that’s why without this scale factor, we would only get one hexbin containing all the points.

Author:
Jessica Kwan
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab