Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mjfulke
Employee
Employee

Create Your Own Custom Map for Power BI

Hi, I’m sharing back with community here (I encourage you to do the same as you come across your own useful Power BI tips and recipes)

 

In this post, I will share how to create a custom map file to use in Power BI.  To start out, add a Shape Map visual to a report in Power BI Desktop:

 

2017-04-27_11-27-39.png

 

Once you add this visual you can pick from lots of included maps as well add your own custom map by clicking Add Map.  

 

 2017-06-16_8-50-41.png

 

 

That's great, but “Where do I get custom maps or better yet how would I create my own map?” you may ask.   Lots of organizations need custom maps for sales districts, service areas, and regions that don't always align nicely to states and zip codes.     

 

How to create your own map

Let's walk through the steps to create your own custom maps using Google Maps and a couple open source tools.  When we’re done, you will know how to make a professional looking map that works extremely well with Power BI.

 

Shape Maps in Power BI use a popular map file format called Topojson.   I first encountered TopoJson when I worked as a D3.js developer.    If you want to learn more about TopoJson/GeoJson you can go here

 

TopoJson is a JSON file that can be quite complex and lengthy. While you could code one in notepad, that would be no fun at best.  

 

Luckily Google Maps provides an on-line tool for creating your own custom maps.

 

Create a custom map in Google Maps

 Go to Google Maps, open "Your Places", Maps, and click Create Map.  Start drawing your own map over the area of the world you are interested in tracing.   I won't go into the details on how to draw a map, but you will find it fairly intuitive and easy.  Use the polygon tool to trace around your custom areas.  

  

IMPORTANT:
To map data to your shapes in Power BI, you want to name your Polygons EXACTLY as they are in your data.  For example, if in your data you have a [Region Name] field and it has a value of "Western Region", you want to name the Polygon shape you drew in Google Maps, "Western Region" if that's the field you will bind to your map's location property.  

 

Once you have a saved map, Export to KML.

 

2017-04-27_11-48-18.png

 

Pick your map layer instead of the "entire map" and check these options:

 

2017-04-27_12-43-46.png

 

Click Download and Save.

 

Now that you have a KML file (another type of mapping file that is based on XML) we need to convert it to JSON.  We must go through a couple of steps to get it into a format Power BI can use.

 

KML to GeoJson
You can use tools like  https://mapbox.github.io/toGeoJson/ to convert KML to GeoJson.  In this tool, you cut and paste the contents of your KML file into the KML window and you will get a GeoJson conversion on the right.  Save the conversion to your workstation in a file with a .json extension. 

 

GeoJson to TopoJson

 We're not done yet.   Now that you have a GeoJson file, you need to run this through a couple of conversions to get it to look nice and export to TopoJson.    In this example, I'm focusing on getting a custom map of the United States projected as "USA Albers projection" which will, for display purposes, move Alaska and Hawaii and scale them so they can be easily viewed with the other 48 states.

 

To do this we can use http://mapshaper.org.    

 

Open your GeoJson file you just created.

 

2017-04-27_12-48-01.png

 

You should now see your custom map displayed.   

 

Depending on your map, you need to do a couple of clean-ups before we're ready to save as TopoJson.   

 

To clean up the file, you need to make sure the map is projected as  WGS84.  To do this, click the Console button (upper-right)

 

2017-04-27_12-51-24.png

 

At the command prompt ($), enter the command -proj wgs84

 

If you want a map in Albers USA projection also enter -proj albersusa

 

If your shapes render as black, you may want to get a look at the boundaries before finishing.  This command will do this for you.

-svg-style fill="white"

 

Finally, save the file as TopoJson by clicking export and selecting TopoJson. 

2017-04-27_12-59-45.png

 Click Export and Save.

 

We're almost done.    I swear!

 

Open your custom map in Power BI Desktop

 

Go back to Power BI Desktop and open your custom map in the format properties of a Shape Map visual

 

2017-04-27_13-16-58.png

 

Select your previously created TopoJson file.  You should now see your map!   If you wish, you can play around with the different types of projections.  

 

Last thing you need to do is bind data to your map.  If you properly named your polygons in Google Maps, you should be able to assign your appropriate data field to the Location property of the map, and then assign a measure value to the color saturation.

2017-04-27_13-22-54.png

 

At this point you should now be feeling like a B.I. rockstar and have a strong urge to show your boss the cool Power BI trick you just learned. 

 

Enjoy and remember Power BI's Community is one of the main things that makes Power BI a great tool.  Take a tip, leave a tip.

70 REPLIES 70

My suggestion is to use mapshaper.org and use the "Simplify" feature.  You will find that by reducing the complexity of your shapes up to as much as 50-60% you can visually get about the same map.  For example, I have a map of all the counties in the U.S. which is approximately 3000 shapes.  The total file size is 1.25 MB.    It's not as much a Power BI problem but a PC/device issue trying to render lots of detailed Polygons.  Use mapshaper to reduce the detail of your shapes and it should render faster.

hdunn
Frequent Visitor

Hi,

FYI. After a few simplification trials, I found a data below 1MB doesn't slow down the report. 4MB data is still too big with my quite powerful PC.

 

My next issue is the location is not recognised. Even though I set automatic Zoom/Selection Zoom on. It doesn't behave the same as the standard map, such as Australian State map.

 

Is there requirement the map data must meet?

 

Thanks

 

Helen

@hdunn your "Name" property in the Google Maps needs to have values that match your data values.   Then it should work and you can set auto-zoom etc. and it will just work.

hdunn
Frequent Visitor

Yes. It have the same number of rows and the name value is the same as I can perform database join using the source dataset. Do I need a column name as "NAME"?

Thank you. I used the simply option in mapshaper and it certaintly helps render faster.

Hi,

Does your custom map work with slice?

Helen 

absolutely works with slicers!

hdunn
Frequent Visitor

Strange. Mine never worked. There is no way to assign the relationship with the map data. Do I need the same physical column names for the location in the data and the json file?

 

hdunn
Frequent Visitor

Thanks for the suggestion. I will give it a try. Hopefully, it won't have the similar behavious as the Esri Map into which I published the same data and used in other GIS applications without problem. It was simplied on the fly when it loaded into the Power BI.

 

Helen 

I believe so as well as Im having the same problem for the last few days. My file sizes are around 25MB and power BI doesnt like it. I imported the statistical areas map of Australia and though it imports fine, you cant do much with it as it freezes and crashes. Hope they fix it.

I initially tried Esri Map option. It generalised so much that you couldn't even recognise the area. 

 

Wonder if anyone has used both maps successfully on the REAL spatial data, not just simple point data.

 

I contacted Esri support, and was told that this product is not supported by Esri and advised to contact MS. I don't know who to contact in Microsoft to discuss both maps. Anyone has idea?

 

I recommand there should a special discussion community of using maps.

 

Helen

BManTN
New Member

Hi, thank you for the tip.  I have searched, but cannot find if there is an easy way to create a custom map for sales districts and regions if those territories are mapped to specific counties or ZIP codes?  For example, we divide the US into 5 regions and 21 districts.  The districts are organized by counties (which may cross state borders).  I have a simple Excel table that has county/state to district to region.  How do you link the counties together to the district, and then the district to the region?

In your example Region->District->County, I would suggest creating a map at the District level by drawing around the counties that make it up. Then use slicer for Region to select Regions (a collection of districts). As of today, shape maps don't support layer for a drill down type effect.
robofski
Resolver II
Resolver II

Great tutorial, can't wait to try it, been wanting to do this for a while but everything I read just sounded Greek to me! This makes it seem very possible. Thanks. 

peterg417
Frequent Visitor

So I managed to get a couple of KML files from our market intelligence peeps, converted to JSon file format and imported it without a hitch. The only thing that surprised me is that I was expecting the custom maps to function as overlays on a map. I want to have our markets to overlay the city of Toronto and surrounding areas, instead of just showing a map of the markets. 

 

Is there a way to do that? If I open the KML file in Google Earth, then it does exactly that.

 

Any help would be appreciated. Thanks

Capstone
Resolver I
Resolver I

I have created custom shapefiles but not by this method. 

 

I followed your steps and created the KML file and copied the contents of it in the KML section in mapbox but when I click download , it says no file created. Any one getting the same issues ?

Clicking download doesn't work for some reason.  I just cut and paste the results into a text editor and save with a .json extension

MPG758
Frequent Visitor

Hi Everyone!

 

I tried mjfulke method to create a power bi map for Portugal (only the continent for now), but when i import the resulting map into power bi, i noticed that our district reegions were not able to be rendered in power bi desktop witch was a major disapointment 😞 .

Is there something else i have to do in order to be able to have the regions available in the continent to assign data specific to each district/region, with this method you explained ?

 

Thank you! 🙂

Anonymous
Not applicable

Hi @MPG758 

 

Were you able to create the map for Portugal?

i had this problem, but solve in another way in this link : http://www.projanco.com/

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.