Mapping data geographically has been a feature in Tableau since version 4.0. However, another way you can utilise Tableau’s mapping capability is to map your points to a custom background, and create your own diagrams. This method allows you to create annotated images, such as site maps, equipment, vehicles and buildings.

In this blog we’re going to see how we can project an image into the background of a visualisation and plot points onto it. This method assumes some prior knowledge in Tableau, such as adding data sources, plotting scatter plots and formatting marks.

How to map to any background in Tableau

Step 1: Collecting and Adding your Data

To start creating your diagram the first thing you will need is an image, we’re going to use this image of a floor plan. You can either upload a file or use a URL of an image on the web.

 

mapping data in tableau: collecting & adding data

 

To map the image in Tableau you will need the size of the map and the coordinates to locate the areas on the image you want to highlight. 

First you need to measure the size of your image. You can do this using an image viewer to find the number of pixels wide and high. If you’re using Windows, right click on the image in file explorer and select properties, and it's in the details tab. If you’re using a Mac, open the image in the Preview app and select the information icon. My image is 688 pixels wide and 419 pixels high.

To locate the points you want to highlight on your image you can either:

  • Use trial and error 
  • Use Tableau to tell you the coordinates, which we will come back to later. 

 

Whichever method you use you will need to create the table of data, in this table include a column for the area name you wish to highlight, location X and location Y.

If you are using Tableau to tell you the coordinates you will still need a datasource to start, I’d recommend using coordinates 1,1. The coordinates we will be using are below.

 

Room

Location X

Location Y

Bedroom 1

180

301

Bedroom 2

104

111

Dining Room

345

106

Kitchen

534

300

Lounge

500

106

Bathroom

632

123

 

Add your coordinates into Tableau as a usual data connection and open a worksheet. 

 

Using Trial and Error to Generate Coordinates

To generate the first round of coordinates use the size of the image to estimate whereabouts on the X and Y axis each point you wish to plot falls. Put this into the dataset for each point and plot these on your image using the next steps. If they don’t fall where you want them to, update the coordinates in your dataset and refresh the data in Tableau. This will move the points to the new coordinates. Repeat until you are happy.

 

Step 2: Adding your Custom Image

The next step is to add your custom background into Tableau. In the Tableau worksheet, open the ‘Map’ menu in the top banner and select ‘Background Images’. The menu will show you a list of data sources you have in the workbook, select the data source with the coordinates.

 

Mapping in Tableau: adding your custom image

This will open the ‘Background Image’ window, select ‘Add Image’. In the ‘Add Background Image’ window, name the image appropriately and upload the image using the ‘Browse’ button, or type a URL link.

The ‘X Field’ and ‘Y Field’ determine where your picture will be placed on your chart, use the pixel data from your picture size here. These tell Tableau where the corners are on the X and Y axis. Generally the ‘Left’ and ‘Bottom’ value will be 0, unless you are not mapping your coordinates from 0.

 

X Field (left to right)

Left: Bottom left X axis (normally 0)

Right: Bottom right X axis (pixels wide)

 

Y Field (top to bottom)

Bottom: Bottom left Y axis (normally 0)

Top: Top left Y axis (pixels high)



mapping in tableau: editing background image

As well as setting up your image you have some additional options in the ‘Options’ tab:

  • Lock Aspect Ratio: ensures the image maintains the original dimensions on the axis, which ensures the picture isn’t distorted. 
  • Always Show Entire Image: avoids part of the image being cropped out of the visual if the data coordinates do not extend the entire image. 
  • Only Show When: allows you to set up filters when to show the background image and when not to.

 

Once you’ve set up your image hit okay and you will return to the ‘Background Images’ window. Make sure the tick box next to the image is ticked and press okay.

Back in the worksheet development area, put your X field on the columns, Y field on the rows and the dimension you want your data split by on the detail card. Your image should automatically appear in the visual. 

 

Generating Coordinates in Tableau

If you are using Tableau to get the coordinates for your images you can do this once your image is in your visualisation. 

Right-click on the image where you want your mark to be and go to annotate > point. A text box similar to the tooltip entry will appear with Location X and Location Y. When you click OK an annotation will show on your image with the X and Y location of the point. Note these values down in your dataset. You can then move the point around the image to collect the coordinates you need.

 

mapping in tableau: generating coordinatesmapping in tableau: how to generate coordinates

 

Formatting the Image

All that’s left is to format your custom image. You can use the zoom functionality the same as in maps to zoom to an appropriate level. You may also want to remove the grid lines to make it less graph-like. Format the marks on the visual in the same way as usual, I tend to make mine a filled circle, bigger and a brighter colour. You should then have something that looks like the below.

 

mapping in tableau: formatting the image

Author
Katie Liddle

Katie Liddle

I help you get insights from your data. Easier. Faster.

Read more articles of this author
Let's discuss your data challenges

Join our community of data enthusiasts

Get industry insights, expert tips and Biztory news sent straight to your inbox with our monthly newsletter.