Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

divisions = EntityValue[Entity["AdministrativeDivision", {_, "Sweden"}], "Entities"]

enter image description here

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

enter image description here

share|improve this answer
1  
Very nice! I did not know this, a taste of the future indeed. :) –  Pickett Mar 23 at 5:22

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"]}

examples

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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