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
- fast(less than 0.01s for each retrieving), simple and convenient.
- cover all the cities around the world.
- 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
- dict_all_cities_region2cities.json
- dict_all_cities_rect2cities.json
8000 cities --- < 1s
- dict_cities_8000_region2cities.json
- dict_cities_8000_rect2cities.json
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)
| File | Size | Uploaded | |
|---|---|---|---|
| Cities-1.1.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Cities-1.1-py2.py3-none-any.whl | Python 2, Python 3 | 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
|