# How to create an interactive map of the 50 states showing certain data in tool tips boxes for health care policy development?

To create a means of displaying information about the distribution of primary care providers, the population density and the average yearly Medicare expenditure per enrollee for each state, I would like to create a US map with the state boundaries indicated, and then display a tool tip box containing the data for that state when the cursor hovers over that state. CountryData["UnitedStates"] does not have a map that includes the state boundaries.

In addition, I would like to colorize the states to indicate the value of a given parameter for that state, such as age-adjusted average yearly cost per Medicare Enrollee, by reference to a color scale.

I have not been able to find the Mathematica 9 code for an interactive US map in the Mathematica demonstrations and I am interested in suggestions or working code that I could use. My level of proficiency with Mathematica 9 is somewhere between beginner and intermediate, so I appreciate the details that might not be necessary for explaining the solution to an experienced user.

• There are three or four questions here that have tried to make USA state maps because CountryData doesn't do them. Have a search through them and see if anything gives you a starting point. Jul 29, 2013 at 21:31
• @SjoerdC.deVries from this question perhaps? Jul 29, 2013 at 21:35
• @cormullion actually just from a Google search. About the 4th hit on the page. Jul 29, 2013 at 21:38
• @bobthechemist They are in there. Look for the STATES.state.name field name. Jul 30, 2013 at 7:05

Part of the code taken from the question posted by @Cormullion

       crimestats =   WolframAlpha[   "Murder rate by state", {{"PropertyRanking:CrimeData", 1},
"ComputableData"}];
crimestats =   MapThread[Rule, {crimestats[[All, 2]], #[[1]] & /@ crimestats[[All, 3]]}];
transform[s_] := StringTrim[s, Whitespace ~~ "(" ~~ ___ ~~ ")"];
polygons =   Thread[transform["PlacemarkNames" /. usa[[1]]] -> ("Geometry" /. usa[[1]])];
stateNames = Extract[stateNames,Position[stateNames, x_ /; x != "Alaska" && x !="Hawaii"]];
origdata = (stateNames /. polygons)[[All, 2 ;;, 1]];
values = stateNames /. crimestats;
colors = Module[{val = values, min, max, int}, min = Min@val;
max = Max@val; int = Floor[#/((max - min)/4)] + 1 & /@ val;
ColorData[8, "ColorList"][[#]] & /@ int];
Show[Graphics[
Table[{EdgeForm[Directive[Black, AbsoluteThickness[0.5]]],
colors[[i]], Tooltip[Polygon[origdata[[i]]],
Column[{stateNames[[i]], values[[i]]}]]}, {i, Length@origdata}],
AspectRatio -> Automatic, ImageSize -> Large]]

• You're missing a preliminary definition for stateNamesstateNames = polygons[[All, 1]];
– rm -rf
Jul 30, 2013 at 2:51
• @rm-rf thanks for fixing. Skipped it during cut an paste. Jul 30, 2013 at 13:27