This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Add-ons / Standard Packages / Miscellaneous  /


Displaying a map.

To make a map of an entire continent, you can give the name of the continent in place of the list of country names. Thus, for example, WorldPlot[Oceania] is equivalent to WorldPlot[{"Indonesia","PapuaNewGuinea","Fiji","Australia","NewZealand"}]. The names of the countries that can be mapped are listed at the end of this section. Note that the names of countries are strings. This means they must be surrounded by quotes when you use them in a list of countries. However, the continent names represent lists and therefore are not strings but symbols. They should not be put in quotes.

  • This loads the package.
  • In[1]:= <<Miscellaneous`WorldPlot`

  • This gives a map of Africa with all countries drawn as white with black outlines.
  • In[2]:= WorldPlot[ Africa ]

  • Here is a map of the world with each country colored with a randomly chosen gray level.
  • In[3]:= WorldPlot[{World, RandomGrays}]

    Specifying the color gray level of maps.

    When you make a map, you can specify the color of each country in several ways. The first is to give an explicit list of graphics directives such as GrayLevel, RGBColor, or Hue. The

    element in this list specifies the color of the map of the

    element in your list of country names. You can also specify the colors by defining your own color function. This color function must take names of countries as arguments and return a color directive. Perhaps the simplest way to create maps with colors is to specify the color function as RandomColors or RandomGrays

    . These two functions use random numbers to assign a color or gray level to each country on your list.

  • Here is a simple color function.
  • In[4]:= shadefunc[country_] :=
    Switch[country, "Canada", GrayLevel[0],
    "Mexico", GrayLevel[.3],
    _, GrayLevel[.6]]

  • The color function causes Canada to be drawn black, Mexico dark gray, and other countries a lighter gray.
  • In[5]:= WorldPlot[{NorthAmerica, shadefunc}]

    A map is simply the representation of a portion of the Earth's surface on a flat page. Since the Earth is nearly spherical, this representation requires that we adopt some scheme for taking the surface of a spherical object and representing it as a flat two-dimensional image. These schemes are called projections. By their very nature, all projections give rise to certain distortions. Various projections have been developed that preserve certain properties of the surface of the Earth while distorting others. An equal-area projection has the property that two regions that have the same area on the map have the same area on the globe. A projection is called conformal if it preserves angular relationships and therefore directions. An azimuthal projection preserves true directions from a central point.
    The projection for a map is specified by the option WorldProjection. You can define your own projection by giving a pure function of two arguments. For example, the default setting for WorldProjection is Equirectangular, which as a pure function is given as WorldProjection->({#2,#1}&). The parentheses around the pure function ensure that Mathematica recognizes it as a single expression. If you define your own projections, it is important to remember that the coordinates in the database are given in minutes. This means that you must convert them to radians before using a built-in Mathematica trigonometric function. Also, the coordinates of the boundaries of countries are given as pairs with the latitude first.


    You can also give the name of a projection as a value for the option WorldProjection. Many of the standard projections are included in this package. These are described below.
    The simplest projection is the equirectangular projectionEquirectangular. This projection simply takes the latitude as the coordinate and the longitude as the coordinate. This projection does not preserve angles or area. Equirectangular is the default setting for WorldProjection.
    The Lambert cylindrical projection

    LambertCylindrical is just an equirectangular projection with the spacing between parallels adjusted so the projection is equal area. This projection is sometimes called the cylindrical equal-area projection.
    In the Lambert azimuthal projectionLambertAzimuthal the globe is projected onto a plane that is tangential to the globe at one point, and then the spacing of parallel circles around the projection point is adjusted to make it equal area. This projection gives true directions from the center point and is sometimes called the azimuthal equal-area projection.
    The sinusoidal projectionSinusoidal belongs to the class of pseudo-cylindrical projections, that is, parallels are straight lines, meridians are curved, and their spacing is adjusted to make it equal area.
    The most popular equal-area projection for world maps is the Mollweide projectionMollweide. The adjustment used to achieve equal areas is fairly sophisticated and involves the solution of a trigonometric equation. This projection is sometimes also called elliptical or homolographic.
    The Mercator projectionMercator is a cylindrical projection that preserves angles but is not equal area. It is produced by adjusting a cylindrical projection that is projected from the center of the Earth. This projection is particularly useful for navigation, as a straight line on the map corresponds to a fixed directional bearing.
    A conic projection is produced by projecting the surface of the Earth onto a cone that is tangential to the Earth along a circle. The Albers conic projectionAlbers is a conic projection that is adjusted to make it equal area. Unlike the other projections, Albers requires you to specify additional information. This takes the form of Albers[


    ]. The two parallels you specify are the parallels along which the scale is correct. A good projection for the United States is Albers[20,60]. The Albers conic projection is sometimes called the Albers equal-area projection.

  • The sinusoidal projection gives little distortion near the equator and the prime meridian, and is therefore very good for showing Africa.
  • In[6]:= WorldPlot[{Africa, RandomGrays},
    WorldProjection -> Sinusoidal]

    Options for WorldPlot. The second set can also be used in WorldGraphics.

    Options for WorldPlot. The second set can also be used in WorldGraphics.

    To specify how the borders of countries are to be drawn, you set the WorldBorders option. The settings for this option can be None, Automatic, or a style list. With the setting Automatic the borders are drawn with the style {GrayLevel[0],Thickness[.001]} unless a style list for the shading of the countries is given. If this is the case, no borders are drawn.
    The style of the frame around the map is controlled by the WorldFrame option. To determine which portion of the frame is to be drawn, specify WorldFrameParts->




    . Each is either or and specifies whether a portion of the frame is drawn () or not (
    ). The sides are ordered clockwise, with the eastern side given first.
    WorldGrid controls the drawing of parallels and meridians. A setting for this option of the form WorldGrid->


    specifies the spacing of the latitude and longitude lines that are drawn beginning with the equator or a prime meridian. A setting of WorldGrid->

    deg is the same as WorldGrid->

    deg,deg. You can explicitly specify which latitude and longitude lines you want drawn with WorldGrid->


    , ...



    , ...

    . The default setting Automatic is equivalent to WorldGrid->30. Note that all settings are given in degrees.
    One of the most time-intensive parts of the plot is clipping polygons or lines that are partially outside the plot range. The way this clipping is done is determined by the option WorldClipping. The default setting Full causes these objects to be properly clipped at the edge of the plot range. To save rendering time you can reset this option at Simple, which causes objects outside the plot range to not be rendered, or None

    , which causes the entire object to be rendered.

  • In this map of Africa the background is light gray, there are no grid lines, and the frame around the map is somewhat thicker than usual.
  • In[7]:= afmap = WorldPlot[Africa,
    WorldBackground -> GrayLevel[0.7],
    WorldGrid -> None,
    WorldFrame -> Thickness[.012],
    WorldProjection -> LambertCylindrical]

    As noted above, a projection is a scheme for transforming latitudes and longitudes on the Earth into and coordinates on a flat page. Each projection involves certain fixed geometric choices. For example, the Lambert azimuthal projection projects the surface of the Earth onto a plane that is tangent at one point. When you specify LambertAzimuthal as the projection, this point is fixed at zero degrees latitude and longitude. You can change the choice of this point by setting the WorldRotation option.
    A value for WorldRotation must be a list of three numbers



    with the first two between and and the last between and . To understand the effect of these numbers, you can imagine the globe in a standard coordinate system with the positive axis coming out of the North Pole and the axis through the equator at the Prime Meridian. The three numbers give the amount of rotation (in degrees) of three sequential rotations. The first is about the axis, the second is about the axis, and the third is about the North Pole in the position where it is after

    the first two rotations.

  • This setting for WorldRotation causes the Earth to be rotated by

    degrees before the projection is applied. The result is a view of the Northern Hemisphere centered at the North Pole.
  • In[8]:= WorldPlot[{World, RandomGrays},
    WorldRotation -> {90, 0, 0},
    WorldRange -> {{0, 90}, {-180, 180}},
    WorldProjection -> LambertAzimuthal]

    WorldPlot works by creating a Mathematica graphics object that represents the map. Each country on the map is given as a Polygon primitive. To make a map from a list of countries, Mathematica must know the vertices of these polygons for each country in your list. These data are contained in the package Miscellaneous`WorldData`, which is automatically loaded when Miscellaneous`WorldPlot`is loaded. As noted above, the vertex data are given as ordered pairs of latitude and longitude expressed in minutes. By convention, latitudes north of the equator are positive while those to the south are negative, and longitudes east of Greenwich are positive and those to the west are negative.
    You can specify your own database of geographic coordinates by setting the option WorldDatabase. The setting for this option is the name of the function that is applied to a country name to yield its polygonal vertices. The names of the countries that appear in your database are specified using the option WorldCountries. The setting for this option is the name of the Mathematica list that contains the allowable country names. The default value is World, which is a list given in the package Miscellaneous`WorldNames`. This package is also automatically loaded when you load Miscellaneous`WorldPlot`.

    Creating and displaying WorldGraphics objects.

    Built-in Mathematica functions like Plot and ListPlot work by building up a Graphics object, and then displaying it. The resulting Graphics object can be manipulated and redisplayed using various options. WorldPlot works in a very similar way, creating a WorldGraphics object and then displaying it. A WorldGraphics object is essentially a Graphics object that has been adapted to work with geographic data. All coordinates given in the primitives Polygon, Line, Point, and Text are given as

    lat,long with the latitude and longitude given in minutes of an arc. You can convert data given in degrees and minutes into minutes using the function ToMinutes. Thus Point[ToMinutes[{{41,

    49},-{87,37}}]] represents a point displayed at the location of Chicago, Illinois, which is at latitude degrees, seconds North and longitude degrees, minutes West. Before a WorldGraphics object is displayed, it is internally converted to a standard Graphics object using the projection specified by the value of WorldProjection


  • Here is the list of the vertices of the polygon that give the map of Ireland.
  • In[9]:= WorldData["Ireland"]


  • This is a list of the latitude and longitude in minutes of two cities in Africa.
  • In[10]:= {capetown, cairo} = ToMinutes[
    {{{-33, -56}, {18, 22}},
    {{30, 3}, {31, 15}}}]


  • You can combine maps with WorldGraphics objects using Show. The map of Africa given by afmap was defined above.
  • In[11]:= Show[{afmap,
    {Dashing[{0.05, 0.03}],
    Line[{capetown, cairo}]}]}]

    Converting into minutes.

    The following countries can be given. Giving the name of the continent is the same as giving the list of names of countries in that continent. World gives the list of all the countries in the world. As noted above, the names of countries are strings and need to be included in quotes. The names of continents are symbols and do not require quotes.

    Countries in the list NorthAmerica.

    Countries in the list Europe.

    Countries in the list SouthAmerica.

    Countries in the list Oceania.

    Countries in the list Asia.

    Countries in the list Asia, continued.

    Countries in the list MiddleEast.

    Countries in the list Africa.