TopoJSON Map Files for Power BI Shape Map

About a month ago, I starting a collection of TopoJSON map files in response to a request on the Power BI Community forum. TopoJSON is D3’s preferred format, which is why Power BI users have suddenly found themselves learning more about it after the Shape Map was released. It is an optimized and lightweight cousin of the more prevalent GeoJSON, but there are not many files available in TopoJSON format. As a result, a subset of Power BI users have been converting files from Shapefile, GeoJSON, and other formats into TopoJSON on their own.

world-countries

I have posted a modest collection of files in a GitHub repository at:
https://github.com/deldersveld/topojson

 

Please make sure that you save the “Raw” version of the .json file. Rather than right-clicking and performing a Save Link As on the links directly in the Read Me, click the link to view a preview of the map, and then right-click on the Raw button at the top and select Save Link As.

json-maps

Here’s a sample of what is available:

  • World map with continents and world map with countries
  • Individual continent maps with countries
  • US counties
  • US congressional districts (2015)
  • US cartogram based on each state’s population
  • Individual US state-level counties
  • Denmark – counties and municipalities
  • Finland – provinces and regions
  • France – departments
  • Germany – regions
  • India – states and districts
  • Japan – prefectures and towns
  • Netherlands – municipalities
  • Norway – counties and municipalities
  • Spain – comunidades autonomas and provincias

The US cartogram is the only one at this time that was not simply a conversion from another source. It was a test of R’s new cartogram package. I took a sample US map from R’s albersusa package and created a map that distorts the states based on their 2014 estimated population. As an aside, if you have some R experience and want to explore alternatives to traditional maps, there is a lot that can be done with R that can then be converted for later use in Power BI.

us-cartogram-2014-est-population.PNG

The most important note is that nearly all of these files personally have been tested for use in Power BI. As a result, users should not encounter some of the distortion issues in Power BI that can sometimes occur when converting a Shapefile or other source into TopoJSON. In many cases, the polygons also have been simplified for performance reasons in Power BI without sacrificing much high-level detail.

If you would like to include a TopoJSON file, post a request in the comments, and I will try to honor it. Please note, however, that I will only convert from an original source. I will not branch from an original source by making custom modifications to shapes.

Advertisements

69 thoughts on “TopoJSON Map Files for Power BI Shape Map

  1. Hi David. Do you have any uk files? I have UK Postcode (area, district, sector) and parliamentary area shp files that i am desperately attempting to get into Power BI

    Like

  2. Hi David do you have UK postcode (area, district, sector) and parliamentary areas? I have been trying to convert shp files i have for ssrs but cant get them to work in Power BI.

    Like

  3. Hi David, thanks a lot for this. Is it possible for you to please separate Canary Islands from the Spanish Map located on your repository? This will help for having 2 shape maps on same report and make a better focus on the data.

    Like

  4. We can use any .KML file and convert that into TOPOJSON file and used them in the custom shape map as well.

    This worked out for me , as i have a customized boundary for Pakistan Map.

    Like

  5. I have created a custom SHP file from scratch (using QGIS), then converted to TopoJSON using the links and help you describe – THANK YOU. The custom shapes show up in Power BI, but the shapes do not have map keys. Clicking “View Map Keys” does not bring up a dialog like it does with the built-in or your maps.

    Do you know what attribute or keys I am missing in my custom SHP file that tells Power BI what to use for map keys?

    Thank you very much.

    Like

    • Try opening the entire “Shapefile”, which is actually a compressed folder with multiple files such as .shp, .dbf, etc. in it. If you open the shp only, you only get the shapes, but the data/keys are actually contained in the dbf.

      Like

      • Thanks for the reply. Perhaps this is exposing more of my ignorance around SHP and QGIS than anything. I understand that there are the multiple files that are associated with the SHP (namely the DBF that contains a lot of that per-feature data). I am creating this SHP file from scratch, not opening an existing one. So the question is more about: after drawing some features in the QGIS design surface, how can I set the data for each feature?

        I know about the attributes for each feature, editing them and see them in the attribute table. But those are NOT what are used by Power BI in terms of map keys. I can see after conversion to TopoJSON – there is a “properties” node for each feature – it’s populated with lots of key/value pairs in legitimate/existing SHP to TopoJSON conversions I’ve seen, but nothing in that collection in my home-grown, made-from-scratch SHP to TopoJSON.

        Hope that makes sense – again, think this ends up being more of a QGIS question, so, apologize for that, just that it then impacts Power BI’s ability to see and use map keys in the TopoJSON file.

        Like

  6. I am working in my college project and planning to use shape map of power bi. Therefore,I need the Topojson file of Pakistan district. Can somebody provide me please. Thanks in advance 🙂

    Like

  7. OK – I figured this out. The QGIS side was actually working fine. Open the entire SHP “set”, including the associated DBF. Any attribute I am adding on a feature *is* getting added to the DBF.

    My mistake was when using http://mapshaper.org I was only adding the SHP file to then get converted. Now I take the extra step and add the DBF file to mapshaper as another “layer”. Nothing gets visually rendered differently in the mapshaper UI, but then when you export as TopoJson, the resulting file has the per-feature properties that are needed and interpreted by Power BI.

    Have a fully working example with various ugly feature shapes that I created from scratch in QGIS, then lit up with colors based on data, in Power BI.

    Thank you for the shoves in the right direction.

    Liked by 1 person

  8. Thank you very much for sharing the TopoJson files for PowerBI Shape maps. Currently I am using the Netherlands municipalties shape map.
    Recently there has been a change in de Dutch municipalities: 3 of them have merged into 1 new municipality. Could you please implement this change into the Json file?

    The old municipalities are: GM0844, GM0846 and GM 0860 (Schijndel, St Oedenrode and Veghel)
    The new one is: GM1948 (Meierijstad)

    Thank you very much!

    Like

    • Unfortunately, I don’t have the capacity to manage localized changes. If it changes in the data source, I can re-convert, but it would have to be altered in the source shapefile first.

      Like

  9. David ,

    How can I change the text coding for topo jason file in order to present the correct letters specific to the Polish language?

    I tried to use text editor to change the map Key but although I corrected letters in the text editor , they were not correct recognized in the PowerBI map keys.

    Like

      • 1. Correct spelling in Polish language: Łódzkie

        2. Topojason file – ‘ as is’ wrong spelling: “VARNAME_1″:”LĂłdzkie”}}

        3. Topojason file – ‘to be’ correct spelling to be presented in PowerBI in accordance with point 1 : “VARNAME_1″:”ĹĂłdzkie”}}

        so there is a need to change the first from “L” to “Ĺ” to have the correct spelling in PowerBI otherwise if i just write in Topojason file : “VARNAME_1″:”Łódzkie”}} I will get in PowerBI “??dzkie” name of the province instead of “Łódzkie”.

        I belive it is becasuse of text codding issue.

        Topojason file source:
        https://github.com/deldersveld/topojson/blob/master/countries/poland/poland-provinces.json

        Like

  10. Hello, and thanks for the hard work.
    Could please add Liberia, with its 15 counties and 136 districts.

    Thanks in advance

    Like

  11. Hello David,

    your work is amazing. It has helped me a lot; an invaluable help. However, I have been working with the “Spain province map”, and I would like to report a bug and suggest a change.

    Both in “province map with Canary Islands” and the “Canary Islands map” itself have an error. Half of the islands are part of the “Las Palmas” province, and the other half are from “Santa Cruz de Tenerife” province. Currently, in your great approach all of them are part of “Las Palmas”.

    They change I want to suggest is:
    -Would it be possible to add an additional name to the provinces? Actually the official name of some provinces is different. I mean, the names you used there are right, but the official name following the very official Government agencies are in this URL: http://www.ine.es/daco/daco42/codmun/cod_provincia_estandar.htm .
    These are the names most of the companies use in their databases. For example, instead of “Valencia” or “València”, the official name is “Valencia/València”, and instead “La Rioja”, the official name is “Rioja, La”.

    Thanks a lot in advance, and thanks again for your job. And sorry for my English.

    Regards!

    Like

    • It would also be great if the distance between Canary Islands and the Peninsula were smaller, the same way you moved Hawaii and Alaska nearer to the continent in the US maps, or at least add a map with this possibility.

      Thanks a lot again.

      Like

    • Hola Sergio,

      estoy intentando conseguir solo el mapa de las islas Canarias corregido con provincias, no se si me lo prodrias facilitar tu,

      Gracias de antemano,

      Un saludo

      Like

  12. Hello, and thanks for the hard work.
    Could please add Nepal, with its 14 zones and 75 Distict.

    Thanks in advance

    Like

  13. Hi david,
    I was attempting to convert a Peruvian shapefile that i had found into TopoJSON using mapshaper.
    After exporting from mapshaper and importing it into Power BI, It doesn’t show correctly.
    I wonder, Is it possible to add Peruvian map?

    shape link:
    http://geoservidor.minam.gob.pe/geoservidor/download.aspx
    (option–>Límite Departamental (Fuente: INEI-2007) – Tamaño 3Mb.)

    Thanks in advance.

    Like

  14. I have been trying to convert a shape file to TopoJSON in Mapshaper, and everything looks ok, but when i add it to PowerBI, the map dont appear as in Mapshaper. What can be the problem? Should i need the key to ben in format like ‘PT.AC’ or can be soomething like an int ‘1234’? I was trying to add the OPorto cities.

    Like

  15. Awesome work, thanks! I am using the World map and it’s working great. I can edit the JSON to remove a country completely, but is there a way that I can ‘disable’ a country in Power BI, so I have a World map that plots country data, but countries that have no data aren’t selectable? Thanks!

    Like

  16. Hi David,

    Thank you for your resources.
    I mostly work with linear networks and related data and the linear geometry is in PostgreSQL Database. Is there a best way to display such kind of geometry type into PowerBI.

    Thank you.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s