There have been some questions dealing with how to draw individual US states since such data doesn't come with Mathematica through its CountryData which offers similar functionality for countries. However, thus far, I haven't seen any questions regarding Swedish counties and municipalities.

How would can I get similar functionality for Swedish counties and municipalities as that which exists in CountryData?


2 Answers 2


You could do this already with AdministrativeDivisionData and GeoGraphics on Raspberry Pi. In general - some taste of the future:

divisions = Entity["Country", "Sweden"][
EntityProperty["Country", "AdministrativeDivisions"]]


divisions = Entity["Country", "Sweden"]["AdministrativeDivisions"]

enter image description here

GeoGraphics[{EdgeForm[Red], Opacity[0.1], Polygon[divisions]}]

enter image description here

  • 2
    $\begingroup$ Very nice! I did not know this, a taste of the future indeed. :) $\endgroup$
    – C. E.
    Mar 23, 2014 at 5:22
  • $\begingroup$ divisions = CountryData["Sweden"]["AdministrativeDivisions"] $\endgroup$
    – garej
    Nov 22, 2015 at 15:30
  • $\begingroup$ EntityValue[Entity["AdministrativeDivision", {_, "Sweden"}], "Entities"] does not work in 10.3.1. Could you update it to the equivalent form that should be used in the current versions? (Maybe when you posted this the syntax was not yet finalized.) $\endgroup$
    – Szabolcs
    Dec 22, 2015 at 9:21
  • 1
    $\begingroup$ @Szabolcs done, thanks for noticing. $\endgroup$ Dec 22, 2015 at 13:40

How easy or hard this is depends on what data source you have. When I tackled this problem I couldn't find any ideal data source, I did however find a map on Wikimedia Commons in the SVG graphics format. Each municipality is stored as a polygon, and each polygon has an identification number. Upon further discovery, we realize that these ids are not random, but actually official identification numbers that we can find on Wikipedia.

By putting the information about municipalities, counties and boundary coordinates together we can create a list with all the necessary information.

Since the list is too large to post here, I've posted it to Pastebin. You find it here.

The following code processes the data to create visualizations. The syntax is meant to be similar CountryData:


{_,_,reg_,points_} ->Which[ret=="Region",reg,ret=="SchematicPolygon",{reg,points},True,reg],
{_,name,reg_,points_}|{_,reg_,name,points_} ->Which[ret=="Region",reg,ret=="SchematicPolygon",{reg,points},True,reg]]

Example usage (country, county and municipality level respectively):

{Sweden["All", "Shape"], Sweden["Västra Götalands län", "Shape"], Sweden["Göteborgs kommun", "Shape"]}



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.