This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
 Obsolete WorldPlot Package Tutorial Functions »
Some of the functionality of the World Plotting Package is now available in CountryData.

# World Plotting Package

 WorldPlot[countrylist] generate a map of the countries named in countrylist WorldPlot[{countrylist,RandomColors}] color the countries with randomly chosen colors WorldPlot[{countrylist,RandomGrays}] use randomly chosen gray levels

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", "Papua New Guinea", "Fiji", "Australia", "New Zealand"}]. The names of the countries that can be mapped are listed at the end of this tutorial. 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 gives a map of Africa with all countries drawn as white with black outlines.
 Out[2]=
Here is a map of the world with each country colored with a randomly chosen gray level.
 Out[3]=
 WorldPlot[{countrylist,colorfunc}] color the countries as specified by colorfunc WorldPlot[{countrylist,colorlist}] color the countries using the list of color directives

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 nth element in this list specifies the color of the map of the nth 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.
The color function causes Canada to be drawn black, Mexico dark gray, and other countries a lighter gray.
 Out[5]=
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.

Projections.

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 projection Equirectangular. This projection simply takes the latitude as the y coordinate and the longitude as the x 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 projection LambertAzimuthal 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.
Another azimuthal projection is the orthographic projection. Orthographic specifies a projection of the sphere with the projection point at infinity. The result looks like a view of the planet as seen from very far away. The projection preserves neither area nor angles.
The sinusoidal projection Sinusoidal 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 projection Mollweide. 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 projection Mercator 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 projection Albers 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[par1, par2]. 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.
 Out[6]=
 option name default value WorldBorders Automatic style to display borders of countries; with None, no borders are drawn WorldCountries World name of the list of allowable country names WorldDatabase WorldData name of the database containing polygon data for countries WorldToGraphics False whether to return a standard Graphics object

Some options for WorldPlot.

 option name default value WorldBackground None style to use for the background polygon WorldClipping Full specify what happens to lines or polygons that are partially outside the plot range WorldFrame Automatic style to use for the frame around the map; with None, no boundary is drawn WorldFrameParts {1,1,1,1} what parts of the frame to draw WorldGrid Automatic locations of parallels and meridians to be drawn WorldGridBehind True whether the grid is drawn behind (True) or in front (False) of the countries WorldGridStyle Thickness[.001] style for the grid WorldPoints 100 number of divisions used in plotting grid lines and clipping polygons WorldProjection Equirectangular function to use for the projection WorldRange Automatic portion of the surface of the Earth to be drawn; specifications must be of form {{minlat, maxlat}, {minlong, maxlong}} WorldRotatedRange False coordinate system to which the range specification is applied; with True, it is applied to the system resulting from WorldRotation WorldRotation {0,0,0} rotation to be applied to coordinates before projection

More options for WorldPlot. These options 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 -> {s1, s2, s3, s4}. Each si is either 0 or 1 and specifies whether a portion of the frame is drawn (1) or not (0). 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->{deg1, deg2} 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->{{lat1, lat2, ...}, {lon1, lon2, ...}}. 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.
 Out[7]=
As noted previously, a projection is a scheme for transforming latitudes and longitudes on the Earth into x and y 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 {deg1, deg2, deg3} with the first two between 0 and 180 and the last between -180 and 180. To understand the effect of these numbers, you can imagine the globe in a standard (x, y, z) coordinate system with the positive z axis coming out of the North Pole and the x 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 y axis, the second is about the z 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 90 degrees before the projection is applied. The result is a view of the Northern Hemisphere centered at the North Pole.
 Out[8]=
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 WorldData, which is automatically loaded when 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 WorldNames. This package is also automatically loaded when you load WorldPlot`.
 WorldGraphics[primitives,options] a graphics object representing a planetary map Show[wg,options] display a WorldGraphics object using the options specified Graphics[WorldGraphics[primitives,options]] convert a WorldGraphics object to a Graphics object

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 41 degrees, 49 seconds North and longitude 87 degrees, 37 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.
 Out[9]=
This is a list of the latitude and longitude in minutes of two cities in Africa.
 Out[10]=
You can combine maps with WorldGraphics objects using Show. The map of Africa given by afmap was defined above.
 Out[11]=
 ToMinutes[deg] convert deg into minutes ToMinutes[{deg,min}] convert when the argument is in degrees and minutes ToMinutes[{deg,min,sec}] convert when the argument is in degrees, minutes, and seconds

Converting into minutes.

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 previously noted, the names of countries are strings and need to be included in quotes. The names of continents are symbols and do not require quotes. The following countries can be given:
 Belize Bermuda Canada Costa Rica Cuba Dominican Republic El Salvador Greenland Guatemala Haiti Honduras Jamaica Mexico Nicaragua Panama Puerto Rico USA

Countries in the list NorthAmerica.

 Albania Andorra Austria Belarus Belgium Bosnia and Herzegovina Bulgaria Croatia Cyprus Czech Republic Denmark Estonia Finland France Germany Gibraltar Greece Hungary Iceland Ireland Italy Latvia Liechtenstein Lithuania Luxembourg Macedonia Moldova Monaco Netherlands Norway Poland Portugal Romania Russia San Marino Serbia and Montenegro Slovakia Slovenia Spain Sweden Switzerland Turkey Ukraine United Kingdom

Countries in the list Europe.

 Argentina Bolivia Brazil Chile Colombia Ecuador French Guiana Guyana Paraguay Peru Suriname Uruguay Venezuela

Countries in the list SouthAmerica.

 Australia Fiji Indonesia New Zealand Papua New Guinea

Countries in the list Oceania.

 Afghanistan Armenia Azerbaijan Bahrain Bangladesh Bhutan Brunei Burma Cambodia China Georgia India Indonesia Iran Iraq Israel Japan Jordan Kazakhstan Kuwait Kyrgyzstan Laos Lebanon Malaysia Mongolia Nepal North Korea Oman Pakistan Philippines Qatar Russia Saudi Arabia Singapore South Korea Sri Lanka Syria Taiwan Tajikistan Thailand Turkey Turkmenistan Uzbekistan Vietnam

Countries in the list Asia.

 Bahrain Egypt Iran Iraq Israel Jordan Kuwait Lebanon Oman Qatar Saudi Arabia Syria Turkey UAE Yemen

Countries in the list MiddleEast.

 Algeria Angola Benin Botswana Burkina Burundi Cameroon CAR Chad Congo Cote d'Ivoire Djibouti Egypt Equatorial Guinea Eritrea Ethiopia Gabon Ghana Guinea Guinea-Bissau Kenya Lesotho Liberia Libya Madagascar Malawi Mali Mauritania Morocco Mozambique Namibia Niger Nigeria Rwanda Senegal Sierra Leone Somalia South Africa Sudan Swaziland Tanzania The Gambia Togo Tunisia Uganda Western Sahara Zaire Zambia Zimbabwe

Countries in the list Africa.