Mapping custom polygons

Tableau supports not only using geographic map tiles, but also drawing and display custom polygons (or closed shapes). This can be helpful when visualizing or emphasizing certain areas in a map or background image.

In this recipe, we will draw custom polygons around two points of interest in Vancouver, Canada:

Mapping custom polygons

Getting ready

To follow this recipe, open B05527_05 – STARTER.twbx. Use the worksheet called Custom Polygon, and connect to the Vancouver Points of Interest data source:

Getting ready

How to do it...

Here are the steps to create the custom polygon areas:

  1. Change the mark type in the Marks card dropdown to Polygon.
  2. Double-click on the Latitude and Longitude appearing under Measures. Make sure you double-click the Latitude and Longitude fields from the data source, not the ones that have the (generated) suffix.
  3. From Dimensions, drag Shape Id to Detail.
  4. From Measures, drag Point to Path in the Marks card.
  5. Go to the Analysis menu, and uncheck Aggregate.
  6. From Dimensions, drag Location to Color in the Marks card.

How it works...

A polygon is a series of points that are connected together to form an enclosed space. To create custom polygons in Tableau, there needs to be a series of points – pairs of x and y coordinates—and a sequence that indicates in which order to walk these points.

In our recipe, I created the points using Interworks' Drawing Power Tool (http://powertoolsfortableau.com/tools/drawing-tool). This is a great online tool that allows you to draw your custom shape on a map or a custom image:

How it works...

I've produced my point data using the Table format, which can be seen on the website's left-hand section. I copied these points to Excel. The original points look like this:

How it works...

To help more easily draw this in Tableau, I added another field, called location. I also changed the shape column header to shape id, so that Tableau will interpret this as a dimension by default instead of a measure:

How it works...

Once this is set up, we simply need to connect to this data source. The latitude and longitude represent the x and y coordinates, respectively. When you double-click these, latitude will be assigned to Rows and longitude to Columns. The shape id will identify each enclosed shape, and the point will specify the path to walk (or the sequence of points to connect).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.32