iso.expand {maps}R Documentation

Identify countries by ISO 3166 codes (2 or 3 letters) or by Sovereignty.

Description

This data set and the simple look-up functions allow to build lists of counrtries for the world map.

Usage

	iso.expand(a, regex=TRUE)
	sov.expand(sov, regex=TRUE)
        iso.alpha(x, n=2)

Arguments

a

A vector of ISO codes. All elements should have the same length, either 2 or 3 letters. Not case sensitive.

sov

A vector of country names. The result is a list of all countries that fall under their sovereignty. Case sensitive, must fit completeley.

regex

If TRUE (default), the return vector has the same length as the input (a or sov), but the entries may be regular expressions. If FALSE, the result is a vector of polygon names. This may be more readable, but the return vector may be longer than the input.

x

Vector of country names, may include colons.

n

An integer identitying which ISO code is required. Allowed values are 2 and 3.

Details

The ISO 3166-1 standard identifies countries by a 2 and 3 letter codes. iso.expand translates these codes into the country names as used by the world data base. iso.alpha does the reverse. Some countries have different ISO codes for different regions (e.g. China:Hong Kong has ISO code HK). In such cases, iso.alpha will return the main code, but iso.expand will return a regular expression that excludes some parts.

Value

iso.expand returns vector of country names. When used as input for map it will plot all the countries as identified either by their sovereignty or by ISO codes. If regex=FALSE the length of the vector may be shorter or longer than the input. If regex=TRUE, the results are concatenated in regular expressions. This format is less readable, but can be used as input e.g. for match.map. iso.alpha always returns a vector of the same length as the input, containing the 2- or 3-letter codes.

NOTE

These functions use regular expressions and the results will often not work well with map(...,exact=TRUE).

References

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

See Also

match.map,map.text,iso3166

Examples

# France and all its overseas departments, territories etc.
sov.expand("France") # France and all its overseas departments, territories etc.

# Canary Islands are not included in map("Spain")
iso.expand("ES")
map(regions=sov.expand("Spain"))

# draw a map with ISO codes as labels:
wm <- map("world", fill=TRUE, col=0, xlim=c(-10,40), ylim=c(30,60))
# take out islands, but you loose e.g. UK, New Zealand, small island states
nam <- grep(":", wm$names, inv=TRUE, val=TRUE)
# ad ISO codes as label
map.text(wm, regions=nam, label=iso.alpha(nam), col=2, exact=TRUE, add=TRUE)

[Package maps version 3.4.2 Index]