Cities is a simple tool for searching cities located at a given longitude and latitude range.
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.
pip install Cities
- fast(less than 0.01s for each retrieving), simple and convenient.
- cover all the cities around the world.
- the author is cute.
Download the city data and put it at any directory you want. Remember to set the path up when you initiate an instance.
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))
the bigger the dict file is, the longer the loading time is.
4million cities --- 12s
8000 cities --- < 1s
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|Cities-1.1-py2.py3-none-any.whl (6.1 kB) Copy SHA256 hash SHA256||Wheel||py2.py3|
|Cities-1.1.tar.gz (5.6 kB) Copy SHA256 hash SHA256||Source||None|