In this blog post, we provide a step-by-step guide into how to create a world shape map in Power BI using custom geographical data.
Power BI provides several options for displaying geographic data, including the Shape Map visual, which are useful when you want to compare values across defined geographic areas.
While Power BI includes several built-in maps, a world map is not one of the standard options available in the Shape Map visual. To create one, you need to import your own geographic boundaries using a custom TopoJSON map file.
Follow along to learn how we set it up in Power BI.
Step 1: Add Shape Map
To begin creating a Shape Map visual in Power BI, add it to your report from the Visualizations pane.
Next, drag your geographic field into the Location field well. In our sample data, we have a column called Country.
At this point, Power BI may display one of the Shape Map visual’s built-in maps. To see the available options, open the Format pane and expand Map settings. From there, you can select from several predefined map types. Note that ‘World’ or ‘All countries’ is not an option from the pre-build map types.
For this tutorial, however, we want to visualize data for countries around the entire world. Since the world geography we need is not available as a built-in map, we’ll create and import our own custom map in the next few steps.
Step 2: Download the World Map Data
Now that we have the Shape Map visual set up, we need geographic boundary data for the countries we want to display.
For this example, we’ll use Natural Earth, a free source of public-domain map data. Go to the Natural Earth Data website, go to the Downloads page, select Cultural from one of the detailed map options. Next, find the Admin o – Countries dataset.
Natural Earth provides its data at several scales. For our map, we’ll use the 1:50m (medium scale) dataset. This provides enough geographic detail for a world-level Power BI visual without adding unnecessary complexity to the map file.
Download the shapefile version of the dataset and extract the downloaded ZIP file. You’ll notice that it contains several files rather than a single map file. Keep these files together as we’ll need them in the next step.
Step 3: Format the Map
Power BI’s Shape Map visual uses the TopoJSON format for custom maps, so the Natural Earth data needs to be converted before we can use it.
For this, we’ll use Mapshaper, a free browser-based tool for working with geographic data. Go to Mapshaper, select Import, and upload the shapefile data you downloaded from Natural Earth.
Once the world map appears in Mapshaper, select Export and choose TopoJSON as the file format. Export the file and save it somewhere you can easily access from Power BI.
At this point, we have a custom world map in the format Power BI needs and just need to import it in Power BI Desktop.
Step 4: Import Custom Map
Now we can bring the TopoJSON file into Power BI.
Select your Shape Map visual, open the Format pane, and expand Map settings. Under Map type, select Custom map, then choose Add a map type and browse to the TopoJSON file you exported from Mapshaper.
Once the file is loaded, Power BI will replace the default map with your custom world geography. If your Country field is already assigned to the Location field well, Power BI will attempt to match those country values with the corresponding regions in the custom map.
Now that you’ve created your world shape map, you may be wanting to a add a diverging-colour legend. This is not something Power BI offers out of the box, but we’ve got you covered!
Working With the World Shape Map
With the custom world map in place, we can now use it to visualize our data.
In this example, we’re mapping population by country, so we add the Country field to Location, then add the Population measure to Color saturation. Power BI will use the country field to match each record in the dataset with the corresponding country in the TopoJSON file.
The countries will then be shaded based on their population, making it easy to see where values are higher or lower across the world.
⚠️ Note: if some countries do not display correctly, check the country names in your data against the names used in the TopoJSON file. For example, differences such as United States versus United States of America can prevent Power BI from matching the data to the correct shape.
Format the Map
With the data displayed, the final step is to format the Shape Map so that the geographic patterns are easier to read.
Start with the Colors settings. Power BI allows you to create a colour gradient based on the measure being displayed. In our population example, countries with lower populations can use a lighter shade, while countries with higher populations use a darker shade.
You can also adjust several other settings depending on how you want the finished map to look:
- Projection: Experiment with the available projections to find the best view for your world map
- Borders: Adjust the colour and thickness of the country borders to make individual regions easier to distinguish
- Blank areas: Set an appropriate colour for countries where no data is available so they can be clearly distinguished from countries with low values
- Legend: Add or format the legend where it helps readers interpret the map
- Tooltips: Include additional measures or attributes that users can see when hovering over a country
Wrapping It Up...
Creating a world Shape Map in Power BI requires a few extra steps, but once the custom map is created, it can be reused to visualize a range of country-level data.
Need Help Getting Started With Power BI?
Our Microsoft Certified consultants can help with the implementation of Power BI in your organization
