This is a tutorial on importing and plotting Mapbox Maps on Power BI. The tutorial is split into 3 parts.

  • The first part covers steps on how to get style URL for the map design and access token to Mapbox.
  • The second part covers details on how to import Mapbox map into PowerBI.
  • Formatting Visuals, measures to get required output.

The dataset chosen is located Here. – Road Crashes for five Years Victoria

Steps to generate Style URL and access token for the generated map:

  1. To retrieve the style URL and access token from Mapbox, you can follow these steps:
  2. Sign in to your Mapbox account or create a new one if you don’t have an account already.
  3. Once you’re logged in, go to the Mapbox Studio website at https://studio.mapbox.com/.
  4. In the Mapbox Studio interface, click on the “Styles” tab located on the left-hand side.
  5. Select the style for which you want to obtain the style URL and access token. If you haven’t created a style yet, you can either create a new one or use one of the default Mapbox styles.
  6. Once you have the desired style selected, click on it to open the style editor.
  7. In the style editor, navigate to the “Share” tab, which is located at the top of the editor interface.
  8. Under the “Share” tab, you will find the style URL and access token.
  9. The style URL is displayed in the “Style URL” field. It typically starts with mapbox://styles/ followed by your username and style ID. This URL is used to access and load your Mapbox style in various mapping applications.
  10. The access token is displayed in the “Access token” field. It is a unique identifier that grants access to your Mapbox account and allows you to make requests to Mapbox APIs and services.

    

Steps to import Mapbox visual into Power BI:

  1. In the “Visualizations” pane on the right-hand side in Power BI desktop, click on “get more visuals” (represented by “…”).
  2. In the “Visualizations” store, search for “Mapbox” in the search bar.
  3. Select the “Mapbox Visual” from the search results and click on the “Add” button to add it to your report.
  4. Once the Mapbox visual is added to your report, it will appear in the “Visualizations” pane.
  5. Double click on the Mapbox icon in visuals to add it to the report.
  6. Drag and drop the Latitude, Longitude fields from your dataset into the appropriate fields of the Mapbox visual under the ‘Build visual’ Tab
  7. Paste the Mapbox style URL and Access Token in the fields as below. To be able to see the Style URL field, select “Custom…” in Map Style 
  8. The report should look like below with all of the latitude and longitude values (based on the designed map on Mapbox yours might look different)

 

Tuning visual, measures to get the required format:

  1. To have the visual’s scale match that of Mapbox paste the Lat, Long and Zoom values form Mapbox as shown below. These can be copied from the left-hand bottom of Mapbox page where the map is designed.

 

  1. Next, we attempt to reduce the number of overlapping coordinate points by creating 2 measures for rounding off the lat and long values. After a few attempts, found out that the below calculation works best in my case.

Rounded_Lat = ROUND(Road_Crashes_for_five_Years_Victoria[LATITUDE]*2,1)/2

Rounded_Long = ROUND(Road_Crashes_for_five_Years_Victoria[LONGITUDE]*2,1)/2

More details on ROUND DAX function can be found here

 

  1. These rounded off values replace the existing Latitude and Longitude values in the visual.
  2. In the Visual tab, turning on the toggle in ‘Circle’ dropdown will let you choose the parameters associated with the points on the report. This is as shown below. The gradient for minimum and maximum values can be selected here.

  1. Apart from the above mentioned steps, there might be requirements for further fine tuning the design format based on the data points. The final MApbox map appears as shown below.

 

This concludes the tutorial for importing and plotting Mapbox maps in Power BI

 

 

Shashanka Rao
Author: Shashanka Rao