10

I'm trying to build a real world map in Minecraft and want a pixel-perfect raster image I can copy pixel for block.

How can I modify

CountryData["World", {"Shape", "Robinson"}]

which gives

bad map

such that:

  • Each country is its own separate color (random colors are fine).
  • The water color is distinct from the background.
  • There are no black border lines (but the borders are still clear from the color difference in countries).
  • There is no anti-aliasing or color blending between regions of different colors, be they countries, water, or the background.
  • I can scale the map to the exact width (or height) in pixels I want.

Sorry if this is asking a bit much. Mathematica is completely new to me and I wasn't getting anywhere fumbling around with CountryData and GeoGraphics and WorldPlot for an hour.

  • What version are you on? – J. M.'s missing motivation Jul 22 '16 at 05:02
  • 1
    @J.M. The pilot release for Raspberry Pi (10.0.0.0). – Calvin's Hobbies Jul 22 '16 at 05:06
  • 2
    Would Graphics[Riffle[CountryData["World", {"SchematicPolygon", "Robinson"}] /. Polygon[{p__?MatrixQ}] :> Map[Polygon, {p}], Unevaluated[RandomColor[]], {1, -2, 2}], Background -> ColorData["Legacy", "Azure"]] suit your needs? – J. M.'s missing motivation Jul 22 '16 at 05:20
  • @J.M. That still appears to have the anti-aliased borders between countries. I can maybe deal with those in an image editor but I'd prefer not to. – Calvin's Hobbies Jul 22 '16 at 05:29
  • What if you use "FullPolygon" instead of "SchematicPolygon"? FWIW: these are all generating vector graphics, which you can easily resize before saving as an image file. – J. M.'s missing motivation Jul 22 '16 at 05:41
  • I still see the borders. Also the water and bg are the same color. (Thanks for helping btw :)) – Calvin's Hobbies Jul 22 '16 at 05:52
  • Then I don't know what "borders" you're seeing; contrast Graphics[{EdgeForm[Black], Riffle[CountryData["World", {"FullPolygon", "Robinson"}] /. Polygon[{p__?MatrixQ}] :> Map[Polygon, {p}], Unevaluated[RandomColor[]], {1, -2, 2}]}, Background -> ColorData["Legacy", "Azure"]] with the previous snippet. Also: can you tell me why the background and water can't be the same color? (Note that the polygons for countries do not have holes corresponding to lakes and other landlocked bodies of water.) – J. M.'s missing motivation Jul 22 '16 at 06:03

2 Answers2

11

With GeoGraphics:

GeoGraphics[{GeoStyling@Opacity@1, RandomColor[], 
    CountryData[#, "SchematicPolygon"]} & /@ Join[CountryData["Continents"], CountryData[]], 
 GeoBackground -> Hue[0.56, .8, .8, .5], GeoRange -> "World", 
 GeoProjection -> "Robinson", Background -> White]

Mathematica graphics

István Zachar
  • 47,032
  • 20
  • 143
  • 291
3

From its doc

Graphics[{Hue[
 2/3 Sqrt[
   1 - (CountryData[#, 
        "IndependenceYear"] /. {DateObject[{y_}] :> y, _Missing ->
          First[DateList[]]})/First[DateList[]]]], 
CountryData[#, "SchematicPolygon"]} & /@ CountryData[]]

which makes it plot countries color coded by the length of their claimed independence. You can plot by any other method.

RoderickLee
  • 273
  • 1
  • 6