This article covers how to visualize data using maps in Metabase. The United States maps used throughout this article were created using the Sample Dataset that comes with every Metabase installation.
- Map types
- Make your data compatible with mapping
- Pin map
- Region map
- Grid map
- Additional features (pin map and grid map)
- Further reading
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 GeoJSON map.
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 United States Map.
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:
- Field types in your metadata
- Country codes in your datasets
To edit metadata, visit the Data Model section in the Metabase Admin, and make sure all your field types are set as a Location data type. For example, in Figure 3 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.”
To create a World Map, make sure that your country codes exactly match the standardized two-letter format specified by the International Organization for Standardization (ISO). If the country codes listed in your database are lowercase or contain extra spaces, Metabase won’t recognize them.
If no columns have the Country or State field type, Metabase will choose pin maps as the map type. With your latitude and longitude fields set correctly, Metabase is able to place pins on the map at those coordinates. In Figure 4, the pins are locating customers, but you can also use a pin map to locate businesses partners, company branch locations, or shipping addresses.
As in Figure 4, hovering over a pin provides additional information.
Other cool things you can do with pin maps are shown in Figure 5:
- 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.
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, as shown in Figure 5, 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.
Skip ahead to additional features to learn more ways to interact with your pin maps.
Grouping people by region can be a great way to detect patterns in your customer base. Figure 6 drills through on Texas to see how user creation has been tracking.
Region maps require your data to have columns with the (correctly formatted) field type “State” or “Country”.
Figure 7 is an example of the regional United States Map. See figure 1 for an example of a regional World Map.
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 maps create a colorful gradient that overlays the map (Figure 8). 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.
To create a grid map, you need to bin latitude and longitude. (Follow along with Figure 9)
Click the Browse Data from the button at the top of the screen. Select Sample Dataset, 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.) Follow Figure 9 by selecting 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 the plus symbol, repeat the steps you took with longitude: select the binning option.
Your map will now match Figure 8 with rectangular boxes of color overlaying areas with data points.
Figure 10 demonstrates multiple ways you can interact with a grid map:
- Hover over a grid element to reveal its coordinates and grouping metric.
- 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.
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.
In Figure 11, 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. As demonstrated in Figure 12, 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. As shown in Figure 13, 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 (Figure 12), the view will remain stationary. If no default view is set, the view will zoom in on the selected area (Figure 13).