Skip to main content

Cities is a simple tool for searching cities located at a given longitude and latitude range.

Project description

Cities is a simple tool for searching cities located at a given longitude and latitude range or a given region(country, state, province). All the cities returned are sorted by the importance of a city and the population density.

Install

pip install Cities

Features

  1. fast(less than 0.01s for each retrieving), simple and convenient.
  2. cover all the cities around the world.
  3. the author is cute.

Required File

Download the city data and put it at any directory you want. Remember to set the path up when you initiate an instance.

Example

from Cities import cities_retriever

cr = cities_retriever.CitiesRetrieverByRect("Sources/dict_all_cities_rect2cities.json")
cities = cr.retrieve_cities(lon_start=-124.71, lon_end=-77.21, lat_start=25.24, lat_end=44.75, num=500) # num is optional, default: 999999
print(cities)
print(len(cities))

cr = cities_retriever.CitiesRetrieverByRegionName("Sources/dict_all_cities_region2cities.json")
cities = cr.retrieve_cities(country="United States", region="Washington", num=500) # region and num are optional
print(cities)
print(len(cities))

Note

the bigger the dict file is, the longer the loading time is.

4million cities --- 12s

  1. dict_all_cities_region2cities.json
  2. dict_all_cities_rect2cities.json

8000 cities --- < 1s

  1. dict_cities_8000_region2cities.json
  2. dict_cities_8000_rect2cities.json

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

Cities-1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

Cities-1.1-py2.py3-none-any.whl (6.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Cities-1.1.tar.gz.

File metadata

  • Download URL: Cities-1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for Cities-1.1.tar.gz
Algorithm Hash digest
SHA256 cea4a9196ae1fa0f42e72f8cdc4da3ede6bb9311de76fafee1df225ca490e54c
MD5 11c657f8f2014c44d066ce96b30a3f49
BLAKE2b-256 dd1aba1b720771c22ea6f20023c5e244978d5c1d8b832fab3005a490350a39b5

See more details on using hashes here.

File details

Details for the file Cities-1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: Cities-1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for Cities-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8ff2fffcb2e8d1184fd1fc9bad228a74da27f346fd428cd663c64eadf3fede0
MD5 09b8d5169573b8bec6b4cf0b323c87a1
BLAKE2b-256 8ef5cd40f5256b6139f71fc177b702733c1822d95a533193f1a9a897644278bc

See more details on using hashes here.

Supported by

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