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. All the cities returned are sorted by the importance of a city and the population density.

Features

  1. fast(less than 0.01s for each searching), 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

cr = CitiesRetriever("Sources/worldcities.csv")
cities = cr.retrieve_cities(-124.71, -77.21, 25.24, 44.75, 50) # starting longitude, ending longitude, starting latitude, ending latitude, the number of the cities 
print(json.dumps(cities, indent=2))

Note

it might take you a little time(37s for building dict, 13s to load the dict) when you first invoke the retrieve method. But the building process would happen only once, and the loading process only occurs when you initiate an instance. The retrieving time is still stay around 0.001s ~ 0.01s(it depends on how many cities you want). The mainly time-consuming part in retrieving is a sorting part.

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-0.4.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

Cities-0.4-py2.py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 2 Python 3

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