Guide to Maps

How to use pin maps, region maps, and grid maps to visualize data in Metabase.

This article covers how to visualize data using maps in Metabase. The maps of the United States used throughout this article were created using the Sample Database that comes with every Metabase installation.

Map types

Metabase features three map types:

  • Pin maps mark specific locations.
  • Region maps group data by country or state.
  • Grid maps distribute a large number of points over a specified area.

Any of these map types can be used with our two default map options: the United States and the world. For a different map (for example, one that focuses on a specific region of the world), you can upload a custom map in GeoJSON format.

An example of the world map with the region mapping visualization.

If you have a column with two-letter country codes, Metabase will automatically select the world map. If your data contains names of U.S. states, or two-letter state codes, Metabase will select the map of the United States.

Make your data compatible with mapping

If you plan on using a map visualization, you’ll need to make sure your data is compatible with map visualizations in two ways:

To edit metadata, go to your Data Model admin settings. Confirm that all your field types are set as a Location data type. For example, the State and Longitude fields both have their corresponding field type listed, but Latitude has no field type. To add the field type, click the dropdown menu in the Type column and select Latitude.

Changing the field type to latitude

To create a world map or US region map, make sure that your country or state codes match the standardized two-letter format specified by the International Organization for Standardization (ISO).

Matches are case-sensitive; if the country or state codes listed in your database are lowercase or contain extra spaces, Metabase won’t recognize them.

Pin map

A pin map represents data geographically using discrete markers, and requires coordinates — latitude and longitude — to generate. Let’s start an example by visualizing the People table found within the Sample Database. Once you’re viewing the table, you’ll notice that this table contains four pieces of geographic information: city, state, latitude, and longitude.

Select Visualization, and scroll to the Map icon. With your latitude and longitude fields set correctly, Metabase will produce a pin map by default, placing markers on the map at those coordinates. The pins are locating customers, but you can also use a pin map to locate businesses partners, company branch locations, or shipping addresses, as long as those records contains coordinates.

Example of a pin map made from the people table. Hovering over one of the pins is revealing additional information about the person represented by the pin.

Hovering over a pin provides additional information.

Other cool things you can do with pin maps:

  • Double click to zoom in on an area.
  • Click and drag the map to move to a different area.
  • Click on a pin to drill-through to additional information.

Drilling through on a pin to access additional information, then selecting the relationship with the Orders table to see all the orders placed by the customer.

If your pin is linked to other tables, or there’s too much information to fit in the tooltip, clicking on the point will take you to a details page that displays a list of fields, as well as a list of connected tables. Clicking a relationship to another table directs you to a list of the instances where the current pin and the other table intersect. In this case, Metabase displays orders placed by that person.

Region map

Region maps display data across a geographic area by coloring parts of that area according to a value. Grouping people by region can be a great way to detect patterns in your customer base. Let’s generate a region map using the same People table within the Sample Database. Summarize the data by selecting the green Summarize button at the top righthand corner of your screen. If you count the number of records by State, Metabase will produce a region map, displaying a map of the United States, with the varying shades representing how many records are present for each state.

Here’s a drill-through on Texas to see how user creation has been tracking.

Drilling through Texas in a regional United States map to information about when users from Texas were created.

Region maps require your data to have columns with the (correctly formatted) field type State or Country.

An example of a regional USA map with data from the People table.

Like the pin map, you can drill through states, but the interface and options are slightly different. With regional maps, you have data points that have been grouped together by state or country, so drilling through will reveal an action menu instead of additional details about a single data.

Grid map

Grid maps create a colorful gradient that overlays the map. Grid maps are an excellent way to visualize answers to questions about where most of your customers come from, or where your company is experiencing the most activity. They are also a great alternative to pin maps for huge quantities of data displayed across a single map.

Map of USA exemplifying a grid map with a bin size of 1 degree. The red areas indicate a greater concentration of data points.

To create a grid map, you need to bin latitude and longitude.

Click Browse Data from the button at the top of the screen. Select Sample Database, open the People table, and click the green Summarize button in the upper right corner. Scroll down to longitude and as you hover over the column name, and the phrase Auto binned and a plus symbol + will appear on the right.

Clicking Auto binned will open a popover with several binning options. (The bigger the number of degrees, the more area each bin will cover on the map.) Select Bin every 1 degree.

The next step is to scroll to latitude. When you hover, you will again see Auto binned and a plus symbol appear on the right. This time, click on the plus symbol +. After selecting it, repeat the steps you took with longitude: select the binning option.

Creating a grid map from the People table by binning latitude and longitude by one degree.

There are different ways you can interact with a grid map:

  • Hover over a grid element to reveal its coordinates and how it is grouped.
  • Double click a grid element to zoom in on the map.
  • Click and drag to move within the map.
  • Single click on a grid element and select Zoom in to have its data points appear as separate grid elements.

Demonstration of grid map features outlined in above list.

Additional features (pin map and grid map)

There are a few more features specific to pin and grid maps to cover:

Save as default view

In addition to the other map features, moving your mouse onto the map, will reveal a couple options in both upper corners. In the upper left corner is a zoom in and zoom out control. In the upper right corner is Save as default view and Draw box to filter.

After using the Zoom in control and refreshing the page, the map resets to the original map display.

Now let’s set a default view. To control the map’s reset position on a page refresh, select Save as default view after you have adjusted your map orientation. This will be the new default view that the map returns to after a page refresh.

To change your default view, simply zoom to your desired view and select Save as default view again; your old default view will be replaced.

Draw box to filter

Filter boxes allow you to filter data by a specific area.

You can click Draw box to filter and mouse over the map. The mouse is now a plus sign. To outline a section of the map, hold your mouse down and drag across the map to create a transparent blue box. Once you’ve outlined your target area, release your mouse, and your map will update to filter for data in the selected area. If you’ve set a default view, the view will remain stationary. If no default view is set, the view will zoom in on the selected area.

Demo using the draw box to filter

Common problems with maps

Choosing an inappropriate field for map coordinates

If you create a question using the People table and ask for a map visualization, Metabase will let you use the record ID as the latitude or longitude. This is a case of “legal but wrong”, and if the administrator of your Metabase installation hasn’t set field types in the data model, you might be able to use other inappropriate fields as map coordinates with your own data.

Not having a map of the region you need

Metabase ships with maps of the world and of the United States. As the introduction to this lesson said, you can upload other maps through the Admin panel. When you do this, you must specify which property of the map identifies the region; your data must then use exactly the same labels.

Forgetting that pin maps may only show a subset of data

Metabase only shows the first two thousand rows as pins on a pin map, both for performance reasons and because a million pins would be incomprehensible. If your data is sorted in some way, those pins may not be representative of the data as a whole. It’s always worth looking at a few histograms to check your assumptions.

Not summarizing data for region and grid maps

You may not want to show a simple count for each region or cell. Instead, you might want to display the total sales, the average time on the website for each user in that region, or some other statistic. Whatever it is, you have to create the summary you need so that there is one value per region or cell.

When adding a map, the browser stops responding or throws an error

Sometimes the GeoJSON files are too big for your browser to handle, and the browser will stop responding or throw an error when trying to render the map. In these cases, you can use the MapShaper tool to reduce the file size. Simply upload your GeoJSON file and use the slider to adjust the number of shapes to render on the map. The higher the slider, the smaller the file, but you’ll lose some details as the file size shrinks, so you may need to play around with the slider to get the right file size for your map.

Further reading

Next: Tables and formatting

Almost everything you can do with the table visualization. Learn how to set up conditional formatting, mini bar charts, value formatting, and more.

Next article