Optimized Choropleth Maps in Microsoft Excel

How to create optimized Choropleth Maps in Excel with a higher resolution and without distortions using Excel 365

Inspired by an idea of my internet friend and highly esteemed colleague Leonid Koyfman, the post US Choropleth Map by County per State – a 4th Option described and provided an Excel workbook with a Choropleth Map of the United States including a second map showing a magnified view of one selected state.

Optimized Chroropleth Maps in Excel (Intro)The code and technique itself worked fine.

However, there was one major disadvantage: during the process of creating the map in Excel, the shapes were slightly distorted. The zoomed map of one state still looked good for e.g. Texas or California, but definitely not for smaller states like Rhode Island or Connecticut.

Today’s post provides a solution to overcome this issue: a way to create a Choropleth Map in Excel without distortions, displaying all counties accurately, no matter at which zoom level. As always, an example workbook is provided for free download.

The Problem

The posts Build your own Choropleth Maps with Excel and Create Excel Choropleth Maps from Shape Files described how to set up a maps in Microsoft Excel using SVG or ESRI Shape files. The files were converted to EMF format first. The EMF was then inserted into Excel and ungrouped to shapes, which then can be color coded based on your own data using the algorithm provided in this article: Faster Choropleth Maps with Microsoft Excel.

Although this worked well in general, the process of ungrouping the EMF slightly distorted the shapes.

This didn’t matter for a map of the United States by county, because the distortions weren’t visible at this zoom level:

Choropleth Map USA by CountiesHowever, when zooming into the map or when magnifying selected states, the distortions turned into a problem.

Larger states with a lot of counties still looked good, even in the magnified version:

Choropleth Map Texas (old version)Other states, however, already made the problem visible, like in the case of New Mexico:

Choropleth Map New Mexico (old version)Finally, the smaller states with only a few counties definitely did not look good anymore, like Rhode Island:

Choropleth Map Rhode Island (old version)The New Version

In the new version of the Choropleth Map for the US by counties with one magnified state (download link see the end of the post), the problem does not exist anymore.

No distortions on the magnified map of e.g. New Mexico:

Choropleth Map New Mexico (new version)And even the smaller states like Rhode Island look fine, now:

Choropleth Map Rhode Island (new version)The “Secret” of the New Version

Actually, there is absolutely no secret. It is just a new version of Microsoft Excel. With Microsoft Excel 365, you can directly insert an SVG file as an image. Simply go to Insert|Pictures, browse for the SVG file and insert it.

Next, select the picture and in Graphics Format, click on Convert to Shape or click on Group|Ungroup.

Convert to ShapeExcel will display a warning message and you have to confirm by clicking on “Yes”:

Warning Message Imported Picture not a GroupDepending on the SVG file you are using, the shapes may still be grouped one or more times.

Ungroup ShapesJust display the selection pane (ALT-F10), select the groups and ungroup one after the other until there is no group left.

If you then zoom the worksheet to the maximum level of 400%, you will see that there is absolutely no distortion of the shapes:

USA by Counties highest Zoom FactorThat’s it. From this point on, all other necessary steps are just as already described here: Build your own Choropleth Maps with Excel (step 4 and following).

With the new feature in Excel 365 to directly import an SVG file as a picture, the process of creating a Choropleth Map in Excel is not only much easier and faster than before, but also produces much better results.

By the way, I already used this for creating Choropleth Maps of Italy in Excel.

Important Remark for Users of earlier Versions of Microsoft Excel

I am not 100% sure about Excel 2019, but I do know that this option was not available in Excel versions 2016 and earlier.

Here is the good news for users of earlier versions, though: Excel 365 is only required to create the map. Once you have the shapes in Excel, the algorithm for Faster Choropleth Maps with Microsoft Excel is also working in all earlier versions of Excel. And so is the workbook provided for download in the next section.

Download Link

Download US Map by County one magnified State (zipped Excel Workbook, 2.8MB)

Many thanks go again to Leonid Koyfman for this idea and all of his invaluable contributions to my blog over the years. Thanks, Leonid. Much appreciated.

Stay tuned.

Comments

7 responses to “Optimized Choropleth Maps in Microsoft Excel”

  1. Microsoft Excel Recalc Or Die Avatar

    Kudos to Leonid Koyfman and you Robert, amazing work!
    Quick question Robert, would maps on “png” format work?
    For example, this one for Perú?
    https://upload.wikimedia.org/wikipedia/commons/1/18/Peru_districts.png
    or this one? (Lima)
    https://upload.wikimedia.org/wikipedia/commons/0/08/Map_Districts_of_Lima_Province_Colors.png

  2. Robert Avatar

    Carlos,
    unfortunately, no, they won’t. You need an SVG or an EMF file to ungroup them in Excel to shapes. This does not work for png or jpg.
    No worries, I will prepare maps of Peru over the weekend and send them to you per e-mail.

  3. Stefan Avatar
    Stefan

    Please, look at:
    there you have all districts on their own..
    https://d-maps.com/continent.php?num_con=90&lang=de
    and Peru with the districts:
    https://d-maps.com/pays.php?num_pay=150&lang=de
    best regards,
    Stefan

  4. Ibrahim Taj Aldin Avatar
    Ibrahim Taj Aldin

    Good morning Robert,
    could u please help me make Excel shapes to Yemen map?
    I have the map in many formats :
    https://data.humdata.org/dataset/yemen-admin-boundaries
    I will really appreciate your help.
    thanks

  5. Latif Avatar
    Latif

    Hi Robert, thank you for the tutorial. Currently you are using 0% as green and moving on to red with 90% and more. How do we change the criteria where it is reverse like 0-10 red and 90-100 green. I tried changing legend propertise but the map does not get the colours as specified in the legend. What is the way to change colour coding to meet specified requirements. It doesn’t seem to be working. Thank you.

  6. Robert Avatar

    Latif,
    you do not have to change the criteria or the calculations in the model.
    You could use e.g. the pre-defined color scale “Red to Blue Contrast”. If you don’t like the blue and want a “Red to Green” scale, adjust one of the pre-defined color scales on worksheet [control] as you like (starting with red and ending with green) and select this color scale on US Map worksheet.

Leave a Reply to Microsoft Excel Recalc Or Die Cancel reply

Your email address will not be published. Required fields are marked *