Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

map.cities

Add Cities to Existing Map


Description

Adds city locations and (optionally) names to an existing map using a specified database.

Usage

map.cities(x = world.cities, country = "", label = NULL, minpop = 0,
maxpop = Inf, capitals = 0, cex = par("cex"), projection = FALSE,
parameters = NULL, orientation = NULL, pch = 1, ...)

Arguments

x

Name of database. See world.cities to determine the structure of the database.

country

If the string country is specified, limit the displayed cities to be from within the specified country, province or state (depending on how the database has been constructed).

label

If TRUE, label all cities. If NULL, the cities will be labelled unless there are 20 or more.

minpop

The minimum value of population below which a particular city will not be shown.

maxpop

The maximum value of population above which a particular city will not be shown.

capitals

Selection of capitals-only display. Capitals may be 1 (country capital), 2 (provincial, state, or regional capital) or 3 (local capital). See world.cities for further information.

cex

The value of cex acts to override the current value of character size expansion.

projection

Boolean or character value. If FALSE (the default), no projection is assumed, if TRUE, the previous projection is used, otherwise a character string that names a map projection to use. See mapproject (in the mapproj library).

parameters

numeric vector of parameters for use with the projection argument. This argument is optional only in the sense that certain projections do not require additional parameters. If a projection does require additional parameters, these must be given in the parameters argument.

orientation

a vector c(latitude, longitude, rotation) describing where the map should be centered and a clockwise rotation (in degrees) about this center.

pch

plotting character to use for marking city location. See points for options.

...

Further plotting parameters may be specified as for the commands points and text.

Details

The database is searched for all cities matching the specified criteria and fitting within the limits of the plot currently displayed. The default database is of all cities that have a population greater than a certain threshold or which are capital cities of a country or island territory. The threshold varies from country to country, but in general is no higher than about 40,000. The data were originally obtained from Stefan Helders' website http://www.world-gazetteer.com, which now redirects to http://www.populationmondiale.com. There are no recent updates available.

There are three supplied databases, world.cities (the default), us.cities and canada.cities. The latter two, which need to be made available by using a 'data()' call, include the state or province name with the city name (thanks to John Woodruff jpwoodruff@irisinternet.net for the state and province information).

Note that if the underlying map is "Pacific-centric", i.e. longitudes exceed 180 degrees, and a projection is used, then the map.cities data must be transformed appropriately.

Value

No value is returned from map.cities.

Side Effects

All cities within the boundaries of the plot containing the current map are added to the plot. Note that it is possible that the boundaries of the plot exceed the boundaries of the map requested, and so more cities than were expected might be shown.

See Also

Examples

map("world", "China")
map.cities(country = "China", capitals = 2)
map("state", "New Jersey")
data(us.cities)
map.cities(us.cities, country="NJ")

maps

Draw Geographical Maps

v3.3.0
GPL-2
Authors
Original S code by Richard A. Becker and Allan R. Wilks. R version by Ray Brownrigg. Enhancements by Thomas P Minka and Alex Deckmyn.
Initial release
2018-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.