0
$\begingroup$

I have the picture below

enter image description hereand I am struggling to put the respective labels on the three cities (namely Shenzhen, Dongying and Zhangye) from which the colored edges come out.

I am using this code

'''

Show[
 GeoGraphics[{
   Polygon[Entity["Country", "China"]],
   OptimalOpenFacilities,
   GeoMarker[OptimalOpenFacilities, OpenFacilities, 
    "Alignment" -> Bottom, "Scale" -> Offset[1000], "Color" -> White]
   },
  GeoBackground -> GeoStyling[{"CountryBorders", "Land" -> GrayLevel[0.6], 
  "Ocean" -> GrayLevel[0.3], "Border" -> Black}, GeoZoomLevel -> 4]],
 ImageSize -> {1600, 975}
 ]

''' where OptimalOpenFacilities and OpenFacilities are the Entities and the names, respectively, of the three cities considered.

Do you have any idea of how to proceed?

Thanks

$\endgroup$
2
  • $\begingroup$ Could you add in the InputForm definitions of OptimalOpenFacilities and OpenFacilities to this post? $\endgroup$
    – Greg Hurst
    Commented Mar 31, 2020 at 13:53
  • $\begingroup$ sure! CityList = CityData[{Large, "China"}]; OptimalOpenFacilities = Select[CityList, QuantityMagnitude[CityData[#, "Population"]] >= 1000000 && QuantityMagnitude[CityData[#, "Population"]] <= 15000000 &]; OpenFacilities = #1 & @@@ Transpose[{CommonName@OptimalOpenFacilities}]; $\endgroup$ Commented Mar 31, 2020 at 18:26

1 Answer 1

0
$\begingroup$

The problem here was that you were specifying the marker as a list of titles, so the code was literally telling Mathematica that the map marker for each location should be the entire list. Below, I've Mapped your data such that each location now has it's own GeoMarker that looks like: GeoMarker[Entity, Name, Options]

Show[
 GeoGraphics[{
   Polygon[Entity["Country", "China"]],
   OptimalOpenFacilities,
   Map[GeoMarker[#[[1]], #[[2]], "Alignment" -> Bottom, 
      "Scale" -> Offset[1000], "Color" -> White] &, 
    Transpose[{OptimalOpenFacilities, OpenFacilities}]]
   },
  GeoBackground -> GeoStyling[{"CountryBorders",
     "Land" -> GrayLevel[0.6],
     "Ocean" -> GrayLevel[0.3],
     "Border" -> Black}
    , GeoZoomLevel -> 4]],
 ImageSize -> {1600, 975}
 ]

Does this match what you were trying to accomplish? enter image description here

$\endgroup$

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.