Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 5 down vote accepted

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

or

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

enter image description here

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

enter image description here

share|improve this answer
2  
Very nice! I did not know this, a taste of the future indeed. :) – C. E. 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
1  
@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"]}

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.