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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
henrituol
Advocate I
Advocate I

World Map Projections in Shape Map

I wanted to share this tip for custom projections in Shape Map in case someone else stumbles into the same issue I had. Also, if someone has a better way to do this, do tell!

 

Issue: I wanted to visualize data on the World map and various countries. From Preview features, Shape map visual seems to be a perfect candidate for this. When I open the Map settings, however, Map type list doesn’t have a world map. That is quickly remedied as there are tons of “world countries” as TopoJSON files that can be used as a Custom map. Yet, this may look a bit odd, because Shape map visual has only three Projections to choose from: Equirectangular, Mercator, and Orhtographic.

 

How to add another projection, for example Robinson, Winkel Tripel, or Natural Earth II?

  1. Download high quality public domain map data from Natural Earth. In my case, I downloaded Small scale data, 1:110m Cultural: Admin 0 – Countries.
  2. Open Mapshaper-tool and select dbf, prj, shp, and shx files from the downloaded and extracted zip.
  3. Open Console from the top right-hand corner. You can write “projections” to list all possible projections. Write -proj-command and projections you want to use, for example: “-proj natearth2”. Also, if there are intersecting lines, run “-clean” to get rid of the warning messages.
  4. Select Export -> TopoJSON and click Export.
  5. Now, if you export this file straight into Power BI Shape Map, it looks really funky. I’m not sure why, but editing TopoJSON’s “scale” and “translate” fixed this issue. That is, a) open the file, b) search for “scale” and change the position of decimal point to left, e.g. “1147.433…” -> 0.01147433…” and “888.725…” -> 0.00888725…” c) search for “translate” and change the position of decimal point to left, e.g. “-16769742.013…” -> “167.6…” and “-9083928.75…” -> “-90.8…”, and lastly d) save file.
  6. Open Power BI Shape Map and its map settings, choose Custom map from Map type, select your edited json-file, and select Projection “Equirectangular”. Now that the TopoJSON file already has proper projection, Power BI’s equirectangular should render the map properly.

Here’s an example of Natural Earth II projection in Power BI Shape Map:

 

shape map natural earth 2.png

5 REPLIES 5
Eli1
New Member

Hi, @henrituol 

 

I followed your steps but when I try to auto-filter the map, I get only thick grey rows - Basically, that resolution won't support auto-filtering. Did you encounter the problem? Any suggestions?

 

thanks a lot

vitstastny
New Member

This works like a charm. I would have two questions for minor changes: 

1) how can I remove Antarctica? (can you provide more information on how to access and use "the clip feature" mentionned in hannibalmads reply?)

2) how can I add Singapore and Hong Kong as separate countries to the global map? 

Thanks for your help! 

Ad 1)
Use the shift-drag box tool on the right. 

hannibalmads_0-1712917574529.png

Then hold Shift and then mark Antarctica with the mouse. After that click on Erase to the right

hannibalmads_1-1712917669736.png

 

 

hannibalmads
Advocate III
Advocate III

An extra tip : You can use Mapshaper to clip the map. However interesting Antarctica is as a continent, I had a request to show revenue across the globe. And Antarctica was irrelevant in that case and it does take up a lot of space in the visual. So by using the clip feature I could exclude the continent from the map.

 

Additionally - from the downloaded json you can extract the countries as a dimension table :

let
    Source = Json.Document(File.Contents("C:\Download\World Map.json")),
    #"From JSON to Table" = Table.FromRecords({Source}),
    #"Navigate to countries" = Table.ExpandRecordColumn(#"From JSON to Table", "objects", {"ne_110m_admin_0_countries"}, {"countries"}),
    #"Expand countries" = Table.ExpandRecordColumn(#"Navigate to countries", "countries", {"geometries"}, {"geometries"}),
    #"List of geometries" = #"Expand countries"{0}[geometries],
    #"Convert List to Table" = Table.FromList(#"List of geometries", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expand Record to properties Column" = Table.ExpandRecordColumn(#"Convert List to Table", "Column1", {"properties"}, {"Column1.properties"}),
    #"Expand properties to selected Columns" = Table.ExpandRecordColumn(#"Expand Record to properties Column", "Column1.properties", {"REGION_UN", "CONTINENT", "NAME_SORT", "ADM0_A3", "ADMIN"}, {"Country Region (UN)", "Country Continent", "Country Sort Order", "Country Key", "Country Name"}),
    #"Set Data Types" = Table.TransformColumnTypes(#"Expand properties to selected Columns",{{"Country Region (UN)", type text}, {"Country Continent", type text}, {"Country Sort Order", type text}, {"Country Key", type text}, {"Country Name", type text}})
in
    #"Set Data Types"

 

Replace the file path as you please.

v-jingzhang
Community Support
Community Support

Thank you for sharing your insight with the community!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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