# Map of Swedish regions?

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?

-

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

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


or

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


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


-
Very nice! I did not know this, a taste of the future indeed. :) – Pickett Mar 23 '14 at 5:22
divisions = CountryData["Sweden"]["AdministrativeDivisions"] – garej Nov 22 '15 at 15:30
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.) – Szabolcs Dec 22 '15 at 9:21
@Szabolcs done, thanks for noticing. – Vitaliy Kaurov Dec 22 '15 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:

graphicsDirectives={RGBColor[0.896,0.8878,0.8548],EdgeForm[GrayLevel[0]]};

findRegion[name_,ret_]:=Cases[muni,If[
name=="All",
{_,_,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]]
];
Sweden[name_,"Region"|"SchematicPolygon"]:=Module[{region},region/;(Length[region=findRegion[name,ret]]>0)];
Sweden[name_,"Shape"]:=Module[{region},ImageReflect@Graphics[Join[graphicsDirectives,{Polygon[#[[2]]]}&/@region]]/;(Length[region=findRegion[name,"SchematicPolygon"]]>0)];


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

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


-