towns: Populated places from naturalearth

View source: R/functions.R

townsR Documentation

Populated places from naturalearth

Description

Select a set of cities; the set can be defined using the id of the country, the fact that it is a capital and the size

Usage

towns(x, size = NULL, capital = FALSE, crs = NULL, shift = FALSE)

Arguments

x

a sf (typically computed using the countries function), or a character that is passed to countries,

size

the minimum size of the cities that have to be retrieved (the default value is NULL and all the cities are retrieved)

capital

if TRUE always retrieve the capitals, even if their size is below the one specified using the size argument

crs

an optional crs which is passed to st_transform

shift

a boolean, if TRUE, st_shift_longitude is used

Value

a sf containing five columns:

  • iso2: the id of the country,

  • iso3: the id of the country,

  • name: the name of the city,

  • capital: a boolean, TRUE for a capital

  • pop: the population of the city,

  • point: a point sfc containing the coordinates of the city

Examples

we <- countries("Western Europe")
towns(we, size = 1E06, capital = TRUE)

necountries documentation built on April 4, 2025, 1:43 a.m.