Skip to main content

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

Metadata

Release files for Cities 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Cities 1.1
File Size Uploaded Provenance
Cities-1.1.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for Cities 1.1
File Interpreter ABI Platform
Cities-1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 11.7 kB

Release files / Cities-1.1.tar.gz

Download URL Cities-1.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cea4a9196ae1fa0f42e72f8cdc4da3ede6bb9311de76fafee1df225ca490e54c
BLAKE2b-256 checksum
How to use checksums
dd1aba1b720771c22ea6f20023c5e244978d5c1d8b832fab3005a490350a39b5
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / Cities-1.1-py2.py3-none-any.whl

Download URL Cities-1.1-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c8ff2fffcb2e8d1184fd1fc9bad228a74da27f346fd428cd663c64eadf3fede0
BLAKE2b-256 checksum
How to use checksums
8ef5cd40f5256b6139f71fc177b702733c1822d95a533193f1a9a897644278bc
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for Cities 1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page