10
$\begingroup$

I'm attempting to insert the county names on a map of Florida:

 counties = 
  Join @@ EntityValue[{Entity[
      "AdministrativeDivision", {"Florida", "UnitedStates"}]}, 
    EntityProperty["AdministrativeDivision", "Subdivisions"]];

 countynames = EntityValue[counties, "CanonicalName"];

countyshortnames = Table[StringDrop[StringDrop[ToString[countynames[[i]]],-30], 1], {i, 1, Length[counties]}];

loc = EntityValue[counties, "Position"];

GeoGraphics[{EdgeForm[{Thick, Black}], GeoStyling["OutlineMap"],Polygon /@ counties, Table[GeoMarker[loc[[j]],Style[countyshortnames[[j]], TextAlignment -> Center, Black, FontSize -> 10, Bold]], {j, 1,Length@countyshortnames}]},GeoBackground -> None, ImageSize -> 1200]

Mathematica graphics

The problem is that the labels turn out very unruly and I would appreciate if anyone can give me some other approach to do this task. Thank you!

$\endgroup$
1
  • $\begingroup$ By the way you can just write countyshortnames=StringDrop[#, -6] & /@ countynames[[All, 1]] $\endgroup$
    – SquareOne
    Commented May 26, 2017 at 1:09

1 Answer 1

11
$\begingroup$

Update:

The use of Geomarker to insert (text) labels is probably not correct as the documentation indicates that the marker type should be a Graphics or Image.

According to @C.E. comment in a related post, instead of using Geomarker to insert labels, it is possible to use directly the Textprimitive. In your case :

GeoGraphics[{EdgeForm[{Thick,Black}],GeoStyling["OutlineMap"],Polygon/@counties,
Table[Text[Style[countyshortnames[[j]],TextAlignment->Center,Black,FontSize->10,Bold],loc[[j]]],
{j,1,Length@countyshortnames}]},GeoBackground->None,ImageSize->1200]

enter image description here

Previous:

The problem seems to be the default "Scale" of the GeoMarker primitive. Setting for example the option "Scale"->1 for all your geomarkers seems to work. That means :

GeoGraphics[{EdgeForm[{Thick, Black}], GeoStyling["OutlineMap"],Polygon /@ counties, 
Table[GeoMarker[loc[[j]],Style[countyshortnames[[j]], TextAlignment -> Center, Black, FontSize -> 10, Bold], 
"Scale"->1], {j, 1,Length@countyshortnames}]},GeoBackground -> None, ImageSize -> 1200]
$\endgroup$
3
  • $\begingroup$ Thank you for your help! Have a great Memorial Day weekend! $\endgroup$ Commented May 26, 2017 at 20:09
  • $\begingroup$ If I wanted to do this for North Carolina, how to get MMA to drop the word "County"? $\endgroup$
    – gotwals
    Commented Jun 19, 2018 at 12:03
  • $\begingroup$ @gotwals Just replace countyshortnames[[j]] with StringDrop[countyshortnames, -6][[j]] $\endgroup$
    – SquareOne
    Commented Jun 19, 2018 at 13:02

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.