Skip to main content

plaincities is a library of places in many languages.

Project description

plaincities is a library of places in many languages. It is based on the geonames database.

Installation

pip install plaincities

Usage

All countries are loaded after initialization but city data has to be loaded explicitly for performance reasons:

from plaincities import Countries
countries = Countries(language='en')
india = countries['IN']
india.load_cities()
kerala = india.states['Kerala']
kochi = kerala.cities['Kochi']
(kochi.latitude, kochi.longitude)
('9.93988', '76.26022')

You can also load cities during initialization:

from plaincities import Countries
countries = Countries(countries_to_load=['IN', 'MX'])
mexico = countries['MX']
mexico.load_cities()
merida = mexico.cities['Mérida']
merida.timezone.key
'America/Merida'

or load by continent:

from plaincities import Countries
countries = Countries(continents_to_load=['AF'])

or load all the cities on the globe!

from plaincities import Countries
countries = Countries(load_all=True)

Switching languages:

from plaincities import Countries
countries = Countries(language='zh', countries_to_load=['CN'])
china = countries['CN']
beijing = china.cities['北京']
(china.name, beijing.name, beijing.ascii_name)
('中国', '北京', 'Beijing')

Suggestions:

from plaincities import Countries
countries = Countries(countries_to_load=['GR'])
greece = countries['GR']
list(greece.cities.suggest('Tesaloniki', threshold=0.7))
['Heraklion', 'Thessaloniki']

Generating language files

Default installation supports English, Turkish, French, Spanish, Chinese, Russian and Arabic. You can setup additional languages after the installation.

from plaincities import generator
Generator('data', 'new_values').generate_values('cities15000.txt', ['ko'], 'ko')
from plaincities import Countries
countries = Countries(countries_to_load=['TH'], path='new_values')
thailand = countries['TH']
thailand.name
'태국'

Contact:

ufuk.kocolu@proton.me

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plaincities-0.3.tar.gz (21.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plaincities-0.3-py3-none-any.whl (22.2 MB view details)

Uploaded Python 3

File details

Details for the file plaincities-0.3.tar.gz.

File metadata

  • Download URL: plaincities-0.3.tar.gz
  • Upload date:
  • Size: 21.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for plaincities-0.3.tar.gz
Algorithm Hash digest
SHA256 b4e8e87bbf479013dd4d302137ece3df570c40c48cfbb6a08a929d297d4d85b5
MD5 4cdb1608f5df4249bab77b1a28177f27
BLAKE2b-256 55952e72c8d0b0144ab0f145a53e0a92e85c46ac9cabed5e8a41bbf7e6fb376a

See more details on using hashes here.

File details

Details for the file plaincities-0.3-py3-none-any.whl.

File metadata

  • Download URL: plaincities-0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for plaincities-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d944abbd0b5b186c5b33115e2ba13c091ec7dd5fa3aa7f8afa3f4d63a290ca1
MD5 764a3e6299ae183bf70092807c7f9648
BLAKE2b-256 f2f5f014995e4a9fded46a26f34e6b29cd5a58e7b25cdbb4e2614feac799371d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page