TopoJSON Map Files for Power BI Shape Map

TopoJSON Map Files for Power BI Shape Map
Reading Time: 3 minutes



About a month ago, I started 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.

Please note that I have only converted from an original source. I will not branch from an original source by making custom modifications to shapes.

Also, check out 10 Ways to Create Maps in Microsoft Power BI to see options other than the Shape Map.

Read 10 Ways to Create Maps in Microsoft Power BI.

[embedyt] https://www.youtube.com/playlist?list=PLyWe5-Lx84g1JrDY6Zh_dfV2oO-Cy3frl;layout=gallery[/embedyt]










182 Comments

    1. If you have a few quick value changes, you can open the topojson file in a text reader and manually replace the map key values.

      For anything more complicated such as adding additional keys, you could try importing the file into mapshaper and then using the “each” command in the console (http://www.mapshaper.org with command reference at https://github.com/mbloch/mapshaper/wiki/Command-Reference). I have not tried that method, but there are some examples in the command reference.

  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

  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.

  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.

      1. olá David excelente trabalho e obrigado pelo se enorme contributo tenho tido grandes dificuldades em criar um ficheiros json de Portugal ao nivel do concelho pode ajudar?

  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.

  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.

    1. 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.

      1. 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.

  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 🙂

  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.

  8. Great work David!

    Could you create a map over Sweden with counties and municipalities? Would be forever grateful, thanks.

  9. Could you create a map over Philippines with counties and municipalities? Would be forever grateful, thanks.

  10. 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!

    1. 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.

      1. I created the json file of south africa, johanesburg wards.
        When i tried loading in powerbi, it shows as a globe, it does not show the borders of wards.

  11. Thank you for what you do.

    Could you please add Algeria with all provinces (48 wilaya).

    Thanks in advance

      1. Can you process the shapefile of Poland including all counties ?

        The file is available here: http://www.gadm.org/download

        The size of the file is much lower

        In case you have access to Poland communes shape file, I would very need it as well in topojason format.
        .

        Thank you so much for your help.

  12. 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.

      1. 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

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

    Thanks in advance

  14. 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!

    1. 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.

    2. 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

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

    Thanks in advance

  16. 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.

  17. 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.

  18. 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!

  19. 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.

  20. Hi! Thanks guys for all the support. Really awesome!

    Can you do Argentina json? I need it!

    Thanks you in advanced!

  21. Hey there! 😀
    I am absolutely loving the maps on here, thank you so much for this!

    I have no idea if this is simple or not, but is it possible to add the towns of Denmark?
    Some towns have data that gets combined because of the municipalities, rendering it “kind of useless”.

    If there’s something I can do myself, please let me know 🙂
    The map is still really useful, so honestly – thank you for this! 😀

    1. The source i have only has municipalities. If you can find a source that provides what you want as a shapefile or geojson, please point me to it and I can look into the license and conversion.

    1. In its current state, the Power BI shape map only handles polygons. That image appears to have some linestrings as well, and those will not render. Discrete colors also were not available when last I looked.

  22. Hi David,

    I really appreciate your work. This data is really useful.

    I have seen topojson map of Pakistan (Province and Division level) on your Github page.

    I have one request, can you please add the map on District level as well, please.

    It will be highly beneficial.

    Thanks in advance.

  23. Hi David, thank you for providing these files.
    Could you add a map of Belgium with its municipalities please?
    Thanks in advance,
    Diego

  24. A legend withe the color saturation scale will be an amazing (and i think needed) feature for the graphs. A graph for Venezuela will be very cool. Great work around here!!

  25. fantastic work! great to see how many countries were added
    Does anyone know were I could find .json files for Switzerland? Ideally with postal code and cantons? thanx

  26. Hi There, I have been trying to create a filled map with no luck and I hope you can point me in the right direction.

    In my data I have a column with the Sales Representatives and the regions that they represent located in US and Canada, but the filled map only recognizes the Ontario region, because the other regions has names such as Gulf Coast, Mountain Region, etc. is any way to map this?

    SalesRepID SRName Region Email Active

    1 Select Northwest Yes
    2 Sales Rep A West Central Yes
    3 Sales Rep B East Central Yes
    4 Sales Rep C North East Yes
    5 Sales Rep D Great Lales Yes
    6 Sales Rep E Mid Atlantic Yes
    7 Sales Rep F Mountain Yes
    8 Sales Rep G Western Canada Yes
    9 Sales Rep H Gulf Coast Yes
    10 Sales Rep I Southern Yes

    And for instance Great Lakes are OH, MI, WI and IL.

    1. The Filled Map uses Bing to lookup place names, so it’s picking up Ontario but nothing else because it corresponds to an administrative boundary. You will not be able to make custom territories with the Filled Map but could with the Shape Map or ArcGIS Maps (if you put your territories into ArcGIS Online and use them as a reference layer).

  27. Hi David,

    I always read your contributions. Do you know when you will have the map of Venezuela available?

    Thank you!

  28. One of the more powerful aspects of shapemap is that you can create a TopoJSON of anything. But I’m having an issue understanding how to really tap that. So I’m not interested in countries, or provinces, or electoral maps, etc… I am interested in say producing a map of our office and all the cubes. Then I want to tie data to those cubes and show that. Is there a place to easily learn how to turn say a visio into topojson, or some MSSQLServer Geo functions and data into a topojson with the right keys to tie into other data.

    Any help would be greatly appreciated.

    1. Unfortunately not that I’m aware of. TopoJSON is a fairly niche format. You might have luck if you can find a way to get Visio to Shapefile, which could then convert to TopoJSON. Also, try out the Visio custom visual from Microsoft and potentially avoid the workaround altogether.

  29. Hi David,
    Please let me know where can I find the topojson map for Indonesia. At Province and City level. couldnt find the city level map for indonesia.

  30. Hi David,

    Would you be able to add Australia’s map for me?

    No one seems to have created any on the web for my country so far 🙁

    Many thanks

  31. Hello,
    Great work! I got problems with the denmark-municipalities.json. When I upload it in PowerBi it causes an error everytime I hover my mouse pointer over the map. All the municipalities are not shown either, all the ones closes to Copenhagen are missing. But it might be a part of the error I dont know.
    I downloaded a map from https://github.com/ok-dk/dagi/blob/master/topojson/kommuner.topojson, which are closely the same, but it wont work either. Perhaps it’s a ME problem 🙂

  32. Hi David,

    I am so glad I came across this blog. I have been struggling to get data correctly converted to topojson.

    I am looking for an update of the South African demarcation boundaries i.e. provincial boundaries, Local Municipalities and District municipalities.

    The data is avail;able from the demarcation board : http://www.demarcation.org.za/site/shapefiles/

    I also have a question ( please excuse the ignorance), if you have converted the above mentioned boundaries, will I end up with 1 topojson file with all the detail embed therein or would it comprise of 3 different topojson filed?

    Thanks for you help.

    1. Power BI has Australia’s states (but not suburb) level. I’ve tended to work on countries so far that are not built-in to the Shape Map.

      1. True it does. But I would like to use the Choropleth map in Power BI to be able to drill down to the suburb level.

        What is the level of effort required and how do I go about doing it, if I have to attempt creating suburb level map for Australia?

  33. Hello David,

    Is there any particular reason, Australia is missing? Can you please add it? I am looking for shape files at the State/Suburb or State/Postcode level. I tried to create a topojson file using the following file:
    “State Suburbs ASGS Non ABS Structures Ed 2011 Digital Boundaries in ESRI Shapefile Format ” from
    http://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/1270.0.55.003July%202011. But the resultant file when imported into Power BI showed a gap in Southern Australia region. I have no experience making such files. Can you please help?

  34. Hi David,

    Your work is excellent and much appreciated for all the power bi users around the world.
    Just wondering whether you can have or can find an australia topojson file / breakdown by suburb but not state?
    i searched everywhere but have no luck.

    Thanks

    Loretta

  35. Is a TopoJson file for Dominican Republic available? I can’t find any on Google. Can you help? Really appreciated.

  36. Hi! I need the map of spain with islands… gran canaria and lanzarote. How I can obtain this???
    Thanksss

  37. Hello Everyone,

    Can someone please assist me with combining the following US states with counties.

    NY, CT, MA, MD & NJ

  38. Hi,
    Great work on this world map,thanks.

    I miss Singapore as a country in the worlmap.
    I would appreciate it if you can add it.

    Note:
    Do you have an instruction on how to add a new country to the worldmap?

  39. Hi David,
    Could you add Singapore?

    Where can I find a tutorial on how to add a country to the json file myself?

  40. Hi David,

    Thanks for the great work! Is it possible to add Sweden on the level of Postal Codes / Zip Codes?

    Regards,

  41. I think this is a fantastic piece of work, it really helps.

    Any chance of adding the EU as a `country` with all its current members or is it not possible to have both a country and a larger selection of countries at the same time in the same file?

  42. Hi David,

    Thank you for amazing maps of Norway 🙂
    From 1.January 2020 the municipality map of Norway will change, do you plan to update this map before the change is applied?
    It would be much appreciated.

    Best regards,
    Nora

  43. Hi,

    Amazing work with the maps, they are extremely useful!
    I have a question related to changes in a map. The Norwegian municipalities are going to be changed in January 2020. Could you please provide a updated version of the map?

    Best regards,
    Nora

    1. Nora, I only convert existing shapefiles and don’t manage new changes in the TopoJSON. If you can track down a shapefile that has the new changes once available, I’d convert it.

  44. Hi,

    The Europe countries file works perfectly on Power bi, so thanks for that.

    I’d also like to have UK maps. I am having trouble converting shape map files to the TopoJson format for UK region (NUTS level 1) and UK Local Authority level.

    Here are the link to the shapefiles

    UK Region: https://geoportal.statistics.gov.uk/datasets/nuts-level-1-january-2018-full-clipped-boundaries-in-the-united-kingdom

    UK local Authority: http://geoportal.statistics.gov.uk/datasets/ae90afc385c04d869bc8cf8890bd1bcd_1

    Would you be able to provide the right format for these?

    Thanks

  45. Hi David,

    I am trying to display City of Detroit along with Counties in Michigan map. I have downloaded and imported the City of Detroit shape file and Michigan Counties shape file to Mapshaper. I have merged 2 layers using “merge-layers” command in Mapshaper console. I am able to see the City of Detroit boundary under Wayne County of Michigan map.

    I have exported in TopoJSON format as a local file. But, when I loaded this custom map to Shape Map visual in Power BI, I am not able to find the City of Detroit’s boundary in Power BI. It is just showing me Wayne County. I have checked Map keys. It is fine. When I filtered City of Detroit in my fields, the Shape Map is approximately zooming in to Detroit’s geographic location in Wayne County.

    I need a separate boundary for City of Detroit to appear so that I can click on either Detroit or rest of Wayne County in my Shape map.

    Can you please help me with what I am missing here? Am I missing missing something in Mapshaper?

    I am sharing the source file download links below.

    http://gis-michigan.opendata.arcgis.com/datasets/cities-v17a/data?where=NAME%20%3D%20%27Detroit%27

    http://gis-michigan.opendata.arcgis.com/datasets/counties-v17a/data

    Thank you,
    Abhinav

  46. Hi David,

    Your Map repository work is awesome. Very helpful.

    I am trying to display City of Detroit along with Counties in Michigan map. I have downloaded and imported the City of Detroit shape file and Michigan Counties shape file to Mapshaper. I have merged 2 layers using “merge-layers” command in Mapshaper console. I am able to see the City of Detroit boundary under Wayne County of Michigan map.

    I have exported in TopoJSON format as a local file. But, when I loaded this custom map to Shape Map visual in Power BI, I am not able to find the City of Detroit’s boundary in Power BI. It is just showing me Wayne County. I have checked Map keys. It is fine. When I filtered City of Detroit in my fields, the Shape Map is approximately zooming in to Detroit’s geographic location in Wayne County.

    I need a separate boundary for City of Detroit to appear so that I can click on either Detroit or rest of Wayne County in my Shape map.

    Can you please help me with what I am missing here? Am I missing missing something in Mapshaper?

    I am sharing the source file download links below.

    http://gis-michigan.opendata.arcgis.com/datasets/cities-v17a/data?where=NAME%20%3D%20%27Detroit%27

    http://gis-michigan.opendata.arcgis.com/datasets/counties-v17a/data

    Thank you,
    Abhinav

  47. Hi David. Thank you for putting these files together. I am having an issue where county names that reside in multiple states (Jefferson) appear with the same data (ie Jefferson county in Colorado will have $4 in sales last year and Jefferson in Oregon will also have $4).

    How can I fix this?

  48. Hi David,

    any chance we can get Greece and Cyprus by city or even by municipality?

    also, is there some step-by-step guide how to build the Power BI compatible map?

    thank you in advance!

  49. Hi david, kindly add Myanmar state and district. I can use it on Qgis and Arcgis , but when convert to mapshapper for Power BI, the map is not working very well.

    thank you so much for your working this to us.

  50. Is there a way you can use multiple maps in a single shape map? I’m having trouble combining them.

    Thank you for creating all of these!

  51. Hello David, thank you for the effort to put this great resource together. Can you please add Ecuador and Ghana. It is urgent. Thank you.

  52. I truly appreciate your work on this! When you get a chance, please update the name of the Kingdom of Eswatini (formerly Kingdom of Swaziland). Very much appreciated – thanks again.

  53. You do great and useful work for people, David !
    But it would also help if you shared a map of Uzbekistan with regions for uploading to Power BI.
    Please

Leave a Reply

%d bloggers like this: