CityData

CityData[name,"property"]

gives the value of the specified property for the city with the specified name.

CityData[name]

gives a list of the full specifications of cities whose names are consistent with name.

Details

  • The full specification of a city is {"city","region","country"}, where "region" is a state, province or other administrative division.
  • Names of cities, regions, and countries are given in standard forms, such as "NewYork", "BritishColumbia", and "UnitedStates".
  • CityData["city"] gives a list of all available cities worldwide that use the name "city", sorted in order of decreasing population.
  • CityData[{"city","country"}] gives the full specifications for all available cities in the specified country that use the name "city". The results are sorted in order of decreasing population.
  • CityData[{"city","country"},"property"] gives the value of "property" for the city with the largest population in the given country that has the specified name.
  • CityData[{"city","region","country"},"property"] gives the value of "property" for the particular city represented by the full city specification {"city","region","country"}.
  • If there is more than one city with a given name in a particular region and country, the standard name for that city will contain additional identifying information, such as a county name.
  • CityData[{All,"region","country"}] gives a list of all available cities in the specified region of a country, sorted in order of decreasing population.
  • CityData[{Large,"region","country"}] gives a list of all large cities in the specified region. Large cities are typically defined as having populations above 100,000.
  • CityData[{All,"country"}] and CityData[{Large,"country"}] give all available cities and all large cities, respectively, in the specified country.
  • CityData[] or CityData[All] gives a list of all available cities in the world.
  • Typical properties for cities include:
  • "Coordinates"latitude, longitude for the city center
    "Elevation"elevation in meters of the city center
    "Latitude"latitude for the city center
    "LocationLink"URI for a map centered on the city
    "Longitude"longitude for the city center
    "Population"estimated total ordinary population
    "TimeZone"current time zone relative to UTC
  • Names and identification-related properties include:
  • "AlternateNames"alternate names
    "Country"country in which the city lies
    "FullName"primary full English name (e.g. "New York, New York")
    "Name"primary short English name (e.g. "New York")
    "Region"state, province, or other administrative division
    "RegionName"English or local name for region
  • CityData["name","property","ann"] gives various annotations associated with a property. Typical annotations include:
  • "Date"date to which the data refers
    "Description"the description of the property
    "Units"units in which the value is given
    "UnitsName"English name for the units used
    "UnitsNotation"notation for the units used
    "UnitsStandardName"Wolfram Language standard name for the units used

Examples

open allclose all

Basic Examples  (6)

Find all available cities in the world named London, sorted by decreasing population:

Find the population of London, England:

Find the population of London, Ontario:

Find the latitude and longitude of the center of London, England:

Give English names for a city:

Large cities (of over 100,000) in Ireland:

Large cities in Ohio:

Find all available cities in Vanuatu:

Scope  (13)

City Names & Identification  (6)

Standard Wolfram Language names omit all spaces:

Cities can be requested using names that contain spaces:

The "Name" property gives traditional names, with spaces:

Specify the Los Angeles in Chile:

All available cities named Fresno in the world:

Cities in the U.S. named Fresno:

Specify Fresno, Texas:

Multiple cities with the same name in a state are identified by county or other information:

The basic names are the same:

The full names of the smaller cities contain county information:

Find alternate names for Beijing:

There is no known city with the name Frog anywhere in the world:

Collections of Cities  (3)

Find all available cities in Tuvalu:

Find large cities (population above 100,000) in Belgium:

Find all available cities in the state of Illinois:

City Information  (4)

The coordinates of the center of Chicago:

The elevation of Chicago in meters:

A link to a web-based map of the city:

The region in which Chicago lies:

Applications  (9)

Create a function to find the nearest large cities to a given position in the U.S.:

Find the three large cities nearest Champaign, Illinois:

Plot the positions of all available cities in Japan:

Find city names that occur in both Germany and Belgium:

Make a rank plot of the populations of cities in several U.S. states:

Plot the large cities in Australia, with tooltips for their names:

Plot larger cities with larger, transparent disks:

Find a traveling salesman tour of the large cities in Germany:

Make a 3D contour map of Colorado based on the elevations of its cities:

Make a scatter plot of population versus elevation for cities in Colorado:

Properties & Relations  (2)

CityData gives cities listed in order of decreasing population:

CountryData can give the largest cities in a country:

Make a Lambert azimuthal projection map, centered on New York City:

Possible Issues  (3)

CityData includes only complete cities, not parts of cities:

Sometimes the name of a city, region and country can all be the same:

There can be multiple cities in one state with the same name:

The smaller ones have county or other identifying information:

Neat Examples  (2)

Find the 10 most common city names in the world:

Find the countries where cities named San Jose exist:

Find the capital cities in the world with the smallest recorded populations:

Find the populations:

Wolfram Research (2007), CityData, Wolfram Language function, https://reference.wolfram.com/language/ref/CityData.html (updated 2014).

Text

Wolfram Research (2007), CityData, Wolfram Language function, https://reference.wolfram.com/language/ref/CityData.html (updated 2014).

CMS

Wolfram Language. 2007. "CityData." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/CityData.html.

APA

Wolfram Language. (2007). CityData. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CityData.html

BibTeX

@misc{reference.wolfram_2024_citydata, author="Wolfram Research", title="{CityData}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/CityData.html}", note=[Accessed: 18-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_citydata, organization={Wolfram Research}, title={CityData}, year={2014}, url={https://reference.wolfram.com/language/ref/CityData.html}, note=[Accessed: 18-December-2024 ]}