labelCountries: to print country labels on a world map

View source: R/labelCountries.r

labelCountriesR Documentation

to print country labels on a world map

Description

Given no arguments it will print country names stored in the 'NAME' column of getMap onto an existing map at the centroids of each country polygon, stored in the 'LAT' and 'LON' columns. Alternatively the user can specifiy a data frame or SpatialPolygonsDataFrame in which case they need to define the column containing the country names (nameCountryColumn) and optionally a 2nd attribute column to print (nameColumnToPlot). First you need to create a map plot, for example using mapCountryData or mapBubbles.

Usage

labelCountries(
  dF = "",
  nameCountryColumn = "NAME",
  nameX = "LON",
  nameY = "LAT",
  nameColumnToPlot = "",
  col = "grey",
  cex = 0.8,
  ...
)

Arguments

dF

dataframe or SpatialPolygonsDataFrame

nameCountryColumn

name of column containing country names to be printed on the map (could also be set to any other column in the dataframe)

nameX

name of column containing the X variable (longitude), not needed if dF is a SpatialPolygonsDataFrame

nameY

name of column containing the Y variable (lattitude), not needed if dF is a SpatialPolygonsDataFrame

nameColumnToPlot

name of an attribute column in the data frame the value of which will be appended to the country names

col

colour for labels, default 'grey', can be e.g. rgb(1,1,0,alpha=0.5)

cex

sizing of labels, default = 0.8

...

other parameters that can be passed to text(), e.g. pos=4 to right, (1=below, 2=left, 3=above)

Value

nothing

Author(s)

andy south

See Also

identifyCountries

Examples


mapCountryData()
labelCountries()

labelCountries(nameColumnToPlot = "POP_EST")



rworldmap documentation built on Oct. 16, 2023, 5:07 p.m.