Shape Map Better than the Filled Map

2017-03-07_12h38_43

I have previously written some blog posts about Map visuals in Power BI. One of them was specifically about Filled Map, titled as Filled Map; the Good, the Bad, the Ugly! Why? you need to read that post to find the reason. In this post I want to explain the power of Shape Map which is one of the visuals Power BI team published recently. This visual is still at preview mode at the time of writing this post. This visual is much more powerful than what it looks. The actual power behind it is that you can have your own map added to it. Let’s take a closer look at this visual with an example. If you want to learn more about Power BI; read Power BI from Rookie to Rock Star.

Maps in Power BI

There are many ways to visualize something on Map in Power BI, some of it are as below;

I have written about them all expect last two. This post focus is on Shape Map, and in another post I’ll explain ArcGIS visual. Hopefully at the end I will write a post about comparison.

Shape Map

Shape Map is a visual first introduced few months ago with the ability to highlight regions (similar to Filled Map), and the power of adding your own map file to it. This feature makes it different from Filled Map, because the normal filled map visualize anything on a Bing map layer, and if for some reason it can’t find that geo location information result won’t be great with that. If you want to see an example of that, read this post; Filled Map, the good, the bad, the ugly! Don’t get me wrong; Filled Map is good at some stage, but there are better ways some other times.

Because Shape Map is still in preview mode (at least at the time of writing this post), you need to enable it in Options section of Power BI Desktop; From File Menu -> Options and Settings -> Options.

2017-03-07_10h30_42

You need to select Shape Map in the list of Preview Features tab;

2017-03-07_10h32_22

After clicking OK. you need to close your Power BI Desktop and re-open it again. You should be able to see Shape Map visual in list of your visuals now.

2017-03-07_10h34_45

Sample Data Set and Demo Files

For this example I will be using an Excel file including all New Zealand regions and population of each region. Why New Zealand? Regions of New Zealand can’t fit great into filled map (I’ve explained it here), so it can be a very good example for Shape Map then. You can download all files for this demo here;

    Enter Your Email to download the file (required)

    How Shape Map Works?

    After enabling the preview feature of Shape Map, get the data from Regions Excel file, which includes data set as below;

    2017-03-07_11h39_16

    When you get data from Power BI Desktop from above data set, Power BI automatically change the data types to preferred data types. Make sure that you get correct data types; Region and Code should be Text, and Population should be Whole number;

    2017-03-07_11h42_10

    Close and Apply query editor, and drag and drop a Shape Map visual in the report page.  To get the first view of this visual, you need to drag and drop a field into it. Start with using Region as the Location, and Use Population as Color Saturation.

    2017-03-07_11h45_07

    As you can see in above image, the first view would be States in USA, which is not exactly what we are looking for. The reason is that Shape Map works based on a predefined map. To select to map, go to Format of this visual, and expand Shape section.

    2017-03-07_11h47_01

    Now you can see that the default Map view is USA: States. You can simply change it to other maps in the list;

    2017-03-07_11h47_48

    There are few maps/shapes in this list, but obviously there are many options missing. For example; New Zealand regional map is missing. Even if you want to use USA Cities Map, or Cities of a specific state in USA you can’t find it here. Don’t turn around with seeing that, Shape Map allows you to add your own Map. If your data set is dealing with any of existing maps, then you don’t need to add a custom map for it. Just use the related map, and you are good to go. If your map is not there, here is the guide to add it;

    Add a Custom Map

    Shape Map allows you add your own custom map! For using this option you need to simply click on Add Map in Shape section of Format of this visual.

    2017-03-07_12h11_04

    The map should be a TOPO JSON file. TOPO JSON is a standard for defining geo location information. in this type of file, information such as boundaries of each region and name/id can be stored. Here is an example TOPO JSON content;

    2017-03-07_12h08_27

    As you can see in the above screenshot, information such as boundaries of each region plus region information listed in the file with JSON format. Don’t panic! You don’t need to write JSON to create this file, there are much easier ways;

    Where to Find Map?

    Normally you can easily find Shape files of every map over internet. For example, here is where I have found Shape files for New Zealand Region map;

    https://koordinates.com/layer/4240-nz-regional-councils-2012-yearly-pattern/download/

    2017-03-07_12h13_35

    In the Koordinates.com website, you can find many other maps, and there are also heaps of other websites that give you Shape file for the map. Shape files cannot be used directly with Shape Map. Shape files are normally a zip file including a bunch of files;

    2017-03-07_12h16_07

    Not all files above are normally part of Shape file zipped directory, but normally .shp, .shx, and .dbf are. Once you have the shape file, you can easily convert it to TOPO JSON. there are heaps of converters for it. Here is one of them which one of students in my courses found it and works perfectly;

    Convert Shape File to JSON

    There are many websites that does the conversion of Shape File to TOPO JSON. as an example ShapeEscape does that perfectly;

    2017-03-07_12h19_08

    All you need to do is to upload shape file (the zip file including everything) into the website, and it will simply show you the map. make sure that you have selected TopoJSON map WITH attributes. To verify it; when you click on a region you should see a pop up text section showing name and id of that region (like screenshot below).

    2017-03-07_12h20_38

    Maps can have variation of details, and depends on that the file size changes, you can select whatever details level you want. for this example, I took the most basic one with precision of 10,000. When you click on download, you can copy the entire JSON code into a text file, and put a .JSON extension for it.

    Now you can simply add the custom map to Shape Map visual;

    2017-03-07_12h25_19

    It will take few seconds for map to load, and then you will see your regional map visualized:

    2017-03-07_12h26_43

    If you cannot see regions color coded, probably the attributes part of map file is missing. Verify that in Format -> Shape section with clicking on “View Map Keys”. You should see region names and their keys. If you see nothing, or names are not correctly populated, then try to convert shape file again (make sure that you get the converted file WITH attributes);

    2017-03-07_12h28_53

    Pros and Cons of Shape Map

    Shape Map despite its simplicity, is very powerful. Think about ability to add your own map, and that means no limit! All you need is just some tools to build your map, and convert it to Topo JSON format. There are many free or paid tools for it. There are however some limitations for this visual, which I hope get fixed before the general availability 🙂 Here are pros and cons in nutshell;

    Advantage: Add any Map!

    It is not common feature in Power BI map visuals, that you can add your own map. I have previously explained about SynopticPanel visual by OKviz which allows you to do that. However that is a custom visual, and this one is a built-in visual. and this one works with the Topo JSON standard of geo location.

    Limitation: General Map Features

    This visual is still in preview mode, and it lacks of many features that can be available for map visuals. for example, you can specify different colors for every region through Legend. However drill down/up is not possible. You cannot add other layers of map to it (for example if you want to add heatmap, or bubbles to it).

    2017-03-07_12h38_43

    Summary

    In summary Shape map in my point of view is a powerful map visual for Power BI especially because of the feature to add your own map. Finding a map isn’t easy with help of Google and websites that does the conversion (such as ShapeEscape). This visual still has some limitations due to preview mode of it, which I believe will be sorted in next few months.

    Download Sample Data Set and Demo Files

    For this example I will be using an Excel file including all New Zealand regions and population of each region. Why New Zealand? Regions of New Zealand can’t fit great into filled map (I’ve explained it here), so it can be a very good example for Shape Map then. You can download all files for this demo here;

      Enter Your Email to download the file (required)

      Save

      Save

      Save

      Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
      Reza Rad
      Trainer, Consultant, Mentor
      Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for 12 continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand, Power BI Summit, and Data Insight Summit.
      Reza is author of more than 14 books on Microsoft Business Intelligence, most of these books are published under Power BI category. Among these are books such as Power BI DAX Simplified, Pro Power BI Architecture, Power BI from Rookie to Rock Star, Power Query books series, Row-Level Security in Power BI and etc.
      He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
      Reza’s passion is to help you find the best data solution, he is Data enthusiast.
      His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.

      7 thoughts on “Shape Map Better than the Filled Map

      • Great blog series about the geo tools in Power BI!
        I tried to download the file -> it says “Thanks! Click on download link below.” but either I´m blind since I cannot find any download-link on this page here (I tried chrome and edge) or it doesn`t work. Thank`s for your help!

        • Thanks Robert.
          You need to scroll down a little bit under that text and will find the link. Let me know if you can’t still find it.
          Cheers
          Reza

      • shape escape is off is their any other site that can help change shape files to json for powerbi

        • If the ShapeEscape website is down, I guess you can google for other similar services, changing a Shape File to JSON should be available by other providers too.
          Cheers
          Reza

      • Thanks Reza, I struggled with the data colors today and realised that I confused the location and legend properties. Did exactly what you describe and it works. @Albert – you can use this site : https://mapshaper.org/ as an alternative to convert your shapefile

      Leave a Reply