EN

CAPIT · API & DATA

Database structure

Worldwide cities database schema: columns, identifiers, types, sources and PostgreSQL restoration.

Sign in with my shared account
Subscribe — from €3/month

Tools and data for your websites, together in one subscription.

In use

Cities on AffectionPlus

A map and table of cities in Madagascar, with search and filters.

Explore Madagascar’s cities

Explore city names, administrative divisions, populations and coordinates, with data provenance.

The free API exposes the 5,000 cities with the highest population values in this database release. This global selection is fixed: country filters never expand it.

Widgets displayed on AffectionPlus.com pages use the entire database, including for visitors without a subscription. On another site, the widget is limited to the free selection unless the site uses a token issued under an active eligible subscription.

Database structure

Each city has one row, identified by id. Main columns are in villes; additional attributes are in caracteristiques, linked by the same id. Missing information remains null, and text codes retain leading zeros.

Population figures do not all refer to the same year or geographic area. Ranking uses population, not estimated urban population.

Identical attributes shared by multiple cities are grouped in caracteristiques_communes and linked through profil_id. These profiles do not create additional cities.

The export contains 1,371,405 cities. Allow about 140 MB for the compressed file and 1.37 GB after restoration, including indexes. PostgreSQL with the pg_trgm extension is required.

createdb world_cities
gzip -dc world-cities.sql.gz | psql -X -v ON_ERROR_STOP=1 -d world_cities
psql -d world_cities -c 'SELECT count(*) FROM villes;'

villes.id = caracteristiques.id
caracteristiques.profil_id = caracteristiques_communes.id

public_cities · city_search · export_scopes · metadata

PropertyTypeSQL columnDescription
admin1stringvilles.admin1Name of the first-level administrative division (region, state, Land, province). Source: GeoNames admin1CodesASCII and API Géo / INSEE (France).
admin1_codestringvilles.admin1_codeComposite administrative code of level 1 (GeoNames or INSEE: prefix). Source: GeoNames / INSEE.
admin1_destringcaracteristiques_communes.admin1_deName of the first-level administrative division in German.
admin1_enstringcaracteristiques_communes.admin1_enName of the first-level administrative division in English.
admin1_esstringcaracteristiques_communes.admin1_esName of the first-level administrative division in Spanish.
admin1_frstringcaracteristiques_communes.admin1_frName of the first-level administrative division in French.
admin1_geonames_idstringcaracteristiques_communes.admin1_geonames_idGeoNames identifier of the region / first-level division. Source: GeoNames admin1CodesASCII.
admin1_iso_codestringcaracteristiques_communes.admin1_iso_codeOfficial ISO 3166-2 code of the region or federated state (e.g. FR-ARA, US-CA, DE-BY). Source: Wikidata (property P300 associated with the region's GeoNames ID).
admin1_itstringcaracteristiques_communes.admin1_itName of the first-level administrative division in Italian.
admin1_nlstringcaracteristiques_communes.admin1_nlName of the first-level administrative division in Dutch.
admin1_plstringcaracteristiques_communes.admin1_plName of the first-level administrative division in Polish.
admin1_ptstringcaracteristiques_communes.admin1_ptName of the first-level administrative division in Portuguese.
admin1_trstringcaracteristiques_communes.admin1_trName of the first-level administrative division in Turkish.
admin2stringvilles.admin2Name of the second-level administrative division (county, district, etc.). Source: GeoNames admin2Codes and API Géo / INSEE (France).
admin2_codestringvilles.admin2_codeComposite administrative code of level 2 (GeoNames or INSEE: prefix). Source: GeoNames / INSEE.
admin2_destringcaracteristiques_communes.admin2_deName of the second-level administrative division in German.
admin2_enstringcaracteristiques_communes.admin2_enName of the second-level administrative division in English.
admin2_esstringcaracteristiques_communes.admin2_esName of the second-level administrative division in Spanish.
admin2_frstringcaracteristiques_communes.admin2_frName of the second-level administrative division in French.
admin2_geonames_idstringcaracteristiques_communes.admin2_geonames_idGeoNames identifier of the second-level division. Source: GeoNames admin2Codes.
admin2_itstringcaracteristiques_communes.admin2_itName of the second-level administrative division in Italian.
admin2_nlstringcaracteristiques_communes.admin2_nlName of the second-level administrative division in Dutch.
admin2_plstringcaracteristiques_communes.admin2_plName of the second-level administrative division in Polish.
admin2_ptstringcaracteristiques_communes.admin2_ptName of the second-level administrative division in Portuguese.
admin2_trstringcaracteristiques_communes.admin2_trName of the second-level administrative division in Turkish.
administrative_rolestringcaracteristiques_communes.administrative_roleNormalized administrative role (national_capital, admin1_seat, admin2_seat…). Source: Derived from the GeoNames feature_code.
administrative_role_destringcaracteristiques_communes.administrative_role_deLabel of the administrative role in German.
administrative_role_enstringcaracteristiques_communes.administrative_role_enLabel of the administrative role in English.
administrative_role_esstringcaracteristiques_communes.administrative_role_esLabel of the administrative role in Spanish.
administrative_role_frstringcaracteristiques_communes.administrative_role_frLabel of the administrative role in French.
administrative_role_itstringcaracteristiques_communes.administrative_role_itLabel of the administrative role in Italian.
administrative_role_nlstringcaracteristiques_communes.administrative_role_nlLabel of the administrative role in Dutch.
administrative_role_plstringcaracteristiques_communes.administrative_role_plLabel of the administrative role in Polish.
administrative_role_ptstringcaracteristiques_communes.administrative_role_ptLabel of the administrative role in Portuguese.
administrative_role_trstringcaracteristiques_communes.administrative_role_trLabel of the administrative role in Turkish.
alternate_namesjsoncaracteristiques.alternate_namesJSON list of known spelling variants, exonyms and transliterations. Source: GeoNames alternateNamesV2 and initial data.
area_km2numbercaracteristiques.area_km2Area in square kilometers (km²). Source: API Géo / INSEE (hectares converted to km²) and Wikidata (P2046).
area_scopestringcaracteristiques.area_scopeExact entity covered by the area (commune:<INSEE> or wikidata_entity:<QID>). Source: API Géo / Wikidata.
area_sourcestringcaracteristiques.area_sourceReference dataset that provided the area (geo-fr:<INSEE> or wd:<QID>). Source: API Géo / Wikidata.
continentstringcaracteristiques_communes.continent; lang → caracteristiques_communes.continent_en, caracteristiques_communes.continent_de, caracteristiques_communes.continent_es, caracteristiques_communes.continent_it, caracteristiques_communes.continent_pt, caracteristiques_communes.continent_nl, caracteristiques_communes.continent_pl, caracteristiques_communes.continent_trContinent name in the language requested by lang; falls back to French. Source: UN M49 / CLDR.
continent_codestringcaracteristiques_communes.continent_codeTwo-letter continent code (EU, AS, AF, NA, SA, OC, AN). Source: GeoNames countryInfo.txt.
coordinate_match_distance_kmnumbercaracteristiques.coordinate_match_distance_kmDistance in kilometers between the source coordinate and the matched GeoNames place. Source: Geodesic calculation (Haversine formula) during matching.
coordinate_match_statusstringcaracteristiques.coordinate_match_statusConfidence status of the coordinate-based matching (name_agrees, coordinates_unique, coordinates_guess, geonames_direct). Source: AffectionPlus geographic validation pipeline.
coordinate_sourcestringcaracteristiques_communes.coordinate_sourceSource of the GPS coordinates: OpenStreetMap when longitude and latitude are provided. Source: OpenStreetMap (ODbL license).
countrystringvilles.countryAlias of country_code: ISO 3166-1 alpha-2 code of the country or territory.
country_codestringvilles.countryISO 3166-1 alpha-2 country or territory code (e.g. FR, GB, DK, GL). Source: GeoNames and verified national context.
country_code_iso3stringcaracteristiques_communes.country_code_iso3Normalized three-letter ISO 3166-1 alpha-3 country code (e.g. FRA, GBR, DNK). Source: GeoNames countryInfo.txt.
country_namestringvilles.country_name; lang → villes.country_name_en, villes.country_name_de, villes.country_name_es, villes.country_name_it, villes.country_name_pt, villes.country_name_nl, villes.country_name_pl, villes.country_name_trCountry name in the language requested by lang; falls back to French. Source: CLDR / Babel.
country_tldstringcaracteristiques_communes.country_tldNational top-level Internet domain ccTLD (e.g. .fr, .uk, .dk). Source: GeoNames countryInfo.txt.
currency_codestringcaracteristiques_communes.currency_codeOfficial ISO 4217 currency code of the country or territory (e.g. EUR, USD, GBP, DKK). Source: GeoNames countryInfo.txt.
data_sourcesstringcaracteristiques.data_sourcesList separated by ';' of all sources used to build the row. Source: Per-row provenance log (osm, gn, wd, insee-2023, geo-fr, cldr, un-m49, iso-3166-2).
demonym_destringcaracteristiques.demonym_deAttested demonym in German.
demonym_enstringcaracteristiques.demonym_enAttested demonym in English.
demonym_esstringcaracteristiques.demonym_esAttested demonym in Spanish.
demonym_frstringcaracteristiques.demonym_frAttested demonym in French. Source: Wikidata P1549.
demonym_itstringcaracteristiques.demonym_itAttested demonym in Italian.
demonym_nlstringcaracteristiques.demonym_nlAttested demonym in Dutch.
demonym_plstringcaracteristiques.demonym_plAttested demonym in Polish.
demonym_ptstringcaracteristiques.demonym_ptAttested demonym in Portuguese.
demonym_scopestringcaracteristiques.demonym_scopeScope to which the demonym applies (city or commune). Source: Wikidata / INSEE.
demonym_sourcestringcaracteristiques.demonym_sourceIdentifier of the Wikidata entity that is the source of the demonym. Source: Wikidata.
demonym_trstringcaracteristiques.demonym_trAttested demonym in Turkish.
demonyms_localjsoncaracteristiques.demonyms_localJSON object of all attested demonym forms by language code. Source: Wikidata (P1549).
density_km2numbercaracteristiques.density_km2Density of inhabitants per km² (calculated only if the dated population and the area have the same scope). Source: Verified calculation from [population] / [area_km2].
departmentstringvilles.admin2; lang → caracteristiques_communes.admin2_en, caracteristiques_communes.admin2_de, caracteristiques_communes.admin2_es, caracteristiques_communes.admin2_it, caracteristiques_communes.admin2_pt, caracteristiques_communes.admin2_nl, caracteristiques_communes.admin2_pl, caracteristiques_communes.admin2_trName of the second-level administrative division in the requested language; falls back to admin2.
duplicate_name_in_countrybooleancaracteristiques_communes.duplicate_name_in_countryBoolean (true / false) indicating whether several cities in the same country share the same ASCII name. Source: Calculation over all GeoNames identifiers of the country.
elevation_mnumbercaracteristiques.elevation_mElevation in meters (only when an explicit measurement is provided). Source: GeoNames.
english_namestringcaracteristiques.english_nameDocumented English name.
enrichment_statusstringcaracteristiques_communes.enrichment_statusOverall matching result (name_coordinates, unmatched, coordinates_guess, geonames_direct…). Source: AffectionPlus pipeline.
feature_codestringcaracteristiques_communes.feature_codeGeoNames classification code of the populated place (PPLC, PPLA, PPLA2, PPL…). Source: GeoNames.
geonames_idstringcaracteristiques.geonames_idNumeric GeoNames identifier of the place. Source: GeoNames.
historical_namestringcaracteristiques.historical_nameOriginal name kept in the source column "nom historique"; it does not necessarily designate a former place name.
idstringvilles.idUnique and stable identifier of the city, kept as text, independent of the country.
importance_tiernumbercaracteristiques.importance_tierHierarchical index from 1 to 5 (1 = national capital or ≥ 1 M inhabitants; 2 = regional capital or ≥ 200k; 3 = administrative seat or ≥ 50k; 4 = ≥ 10k; 5 = locality). Source: Algorithmic calculation from [administrative_role], [feature_code] and [population].
languages_officialjsoncaracteristiques_communes.languages_officialJSON list of applicable official language codes. Source: Wikidata (P37) and GeoNames countryInfo.txt.
languages_scopejsoncaracteristiques_communes.languages_scopeJSON object specifying whether the languages apply to the city (city) or the country (country). Source: Language scope metadata.
languages_sourcejsoncaracteristiques_communes.languages_sourceJSON object indicating the source of the official and spoken languages. Source: Wikidata and GeoNames countryInfo.
languages_spokenjsoncaracteristiques_communes.languages_spokenJSON list of documented spoken or used languages. Source: Wikidata (P2936) and GeoNames countryInfo.txt.
languages_yearstringcaracteristiques_communes.languages_yearReference year of the language data when dated. Source: Wikidata.
latitudenumbervilles.latitudeGPS latitude in decimal degrees (WGS84), maximum local precision retained. Source: OpenStreetMap (ODbL) and compatible GeoNames matching.
local_namesjsoncaracteristiques.local_namesDocumented local variants, in JSON format.
longitudenumbervilles.longitudeGPS longitude in decimal degrees (WGS84), maximum local precision retained. Source: OpenStreetMap (ODbL) and compatible GeoNames matching.
municipality_codestringcaracteristiques.municipality_codeOfficial municipality code (notably the INSEE code in France). Source: API Géo / INSEE.
namestringvilles.name; lang → villes.name_en, villes.name_de, villes.name_es, villes.name_it, villes.name_pt, villes.name_nl, villes.name_pl, villes.name_trName in the language requested by lang; falls back to French if this variant is missing.
name_asciistringcaracteristiques.name_asciiCity name in pure ASCII characters (no accents), ideal for indexing and search. Source: GeoNames asciiname.
name_languagestringlang ← villes.name_languages (bitmask)Attested language of the returned name; fr when the requested variant is missing.
name_local_phoneticstringcaracteristiques.name_local_phoneticReading aid in the Latin alphabet for names in non-Latin scripts. Source: GeoNames Latin variants and English name as fallback.
official_websitestringcaracteristiques.official_websiteOfficial website of the municipality or locality. Source: Wikidata (P856).
phone_prefixstringcaracteristiques_communes.phone_prefixInternational telephone dialing code of the country or territory (e.g. +33, +44, +1). Source: GeoNames countryInfo.txt.
populationnumbervilles.populationDocumented number of inhabitants (empty cell if unknown, never 0 by default). Source: INSEE (2023 municipal populations), Wikidata (P1082) or GeoNames depending on [population_source].
population_propernumbercaracteristiques.population_properStrict municipal population (within the administrative limits of the commune / locality). Source: INSEE (2023 municipal populations), Wikidata (P1082 municipal) or GeoNames.
population_scopestringcaracteristiques.population_scopeGeographic scope of the population (commune, wikidata_entity, geonames_place). Source: Enrichment pipeline traceability.
population_sourcestringcaracteristiques.population_sourceExact source of the population figure (insee-2023, wd:<QID>, gn:<id>, original_unverified). Source: Enrichment pipeline traceability.
population_urbannumbercaracteristiques.population_urbanPopulation of the agglomeration / urban area / metropolis attached to the city. Source: Wikidata (urban and metropolitan areas P1082) and GeoNames spatial agglomeration calculation (excluding PPLX sub-districts).
population_urban_sourcestringcaracteristiques.population_urban_sourceSource of the urban population (wd:<QID>, gn_agglomeration or proper_only). Source: AffectionPlus urban agglomeration traceability.
population_yearstringcaracteristiques.population_yearReference year of the census or population estimate. Source: INSEE (2023) or Wikidata point in time qualifier (P585).
postal_code_formatstringcaracteristiques_communes.postal_code_formatOfficial postal code format / mask of the country (e.g. ##### in France). Source: GeoNames countryInfo.txt.
postcodestringcaracteristiques.postcodeOne or more postal codes separated by semicolons (;), leading zeros preserved. Source: API Géo / La Poste (France), GeoNames Postal Codes, Wikidata or initial file.
postcode_sourcestringcaracteristiques.postcode_sourceSource of the postal codes (geo-fr, gn-postal, wd, original_unverified). Source: Postal traceability.
postcode_statusstringcaracteristiques.postcode_statusPostal coverage quality (commune_codes, documented_not_exhaustive, partial_codes, original_unverified). Source: Postal coverage diagnostic.
regionstringvilles.admin1; lang → caracteristiques_communes.admin1_en, caracteristiques_communes.admin1_de, caracteristiques_communes.admin1_es, caracteristiques_communes.admin1_it, caracteristiques_communes.admin1_pt, caracteristiques_communes.admin1_nl, caracteristiques_communes.admin1_pl, caracteristiques_communes.admin1_trName of the first-level administrative division in the requested language; falls back to admin1.
source_idstringvilles.idAlias of id: identifier of the same city.
subregion_code_m49stringcaracteristiques_communes.subregion_code_m49Official United Nations M49 numeric code of the geographic subregion (e.g. 155, 039). Source: United Nations — M49 statistical classification.
subregion_m49stringcaracteristiques_communes.subregion_m49; lang → caracteristiques_communes.subregion_m49_en, caracteristiques_communes.subregion_m49_de, caracteristiques_communes.subregion_m49_es, caracteristiques_communes.subregion_m49_it, caracteristiques_communes.subregion_m49_pt, caracteristiques_communes.subregion_m49_nl, caracteristiques_communes.subregion_m49_pl, caracteristiques_communes.subregion_m49_trName of the UN M49 subregion in the language requested by lang; falls back to French.
timezonestringcaracteristiques_communes.timezoneIANA time zone identifier (e.g. Europe/Paris, America/New_York). Source: GeoNames.
updated_atstringcaracteristiques.updated_atDate of the last enrichment or verification processing of the row (YYYY-MM-DD). Source: AffectionPlus pipeline.
wikidata_idstringcaracteristiques.wikidata_idWikidata entity identifier (e.g. Q90 for Paris). Source: Wikidata (via property P1566 GeoNames ID or P374 INSEE).
wikipedia_languagestringcaracteristiques.wikipedia_languageLanguage code of the Wikipedia URL provided (e.g. fr, en, de). Source: Extracted from the subdomain of [wikipedia_url].
wikipedia_urlstringcaracteristiques.wikipedia_urlWikipedia link kept from the selected source. The language of the link is given by wikipedia_language; this link does not change with the lang parameter.

Sources and licenses

Population figures do not all refer to the same year or geographic area. Ranking uses population, not estimated urban population.

population_urban_source = gn_agglomeration means a heuristic estimate, not an official census. population_source = original_unverified means an uncorroborated historical value. Open licenses also apply to purchased data: attribution and, for a derivative database covered by ODbL, share-alike obligations. Payment covers the service and does not remove redistribution rights granted by those licenses.

Terms of use