Geonames data for continents, cities and US states.
Project description
A Python library that provides functions to retrieve names, ISO and FIPS codes of continents, countries as well as US states and counties as Python dictionaries. The country and city datasets also include population and geographic data.
Geonames data is obtained from GeoNames.
Installation
To install geonamescache, run:
$ sudo pip install geonamescache
Or, if necessary:
$ sudo easy_install geonamescache
Usage
A simple usage example:
import geonamescache gc = geonamescache.GeonamesCache() countries = gc.get_countries() # print countries dictionary print(countries) # you really wanna do something more useful with the data...
Methods
Currently geonamescache provides the following methods, that return dictionaries with the requested data:
get_continents()
get_countries()
get_us_states()
get_cities()
get_countries_by_names()
get_us_states_by_names()
get_cities_by_name(name)
get_us_counties()
In addition you can search for cities by name.
search_cities(‘NAME’)
This function returns a list of city records that match the given NAME. By default the alternatenames attribute is searched for matches.
Mappers
The mappers module provides function(s) to map data properties. Currently you can create a mapper that maps country properties, e. g. the name property to the iso3 property, to do so you’d write the following code:
from geonamescache.mappers import country mapper = country(from_key='name', to_key='iso3') iso3 = mapper('Spain') # iso3 is assigned ESP
Contributing
Fork the repository on GitHub
Commit your changes to the develop branch
Write test(s) for any new feature
Push your changes and send a pull request
If you wish to build the data from scratch, run make dl and make tojson.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file geonamescache-1.3.0.tar.gz
.
File metadata
- Download URL: geonamescache-1.3.0.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a1fc774a3282d324952b87eb5c2c13684055e68e829526909c76c2fffb84f8f |
|
MD5 | 6a7117173e855366fa714aba595724be |
|
BLAKE2b-256 | 716b9190135ee0791d5a876a6117278b965d4e2674e0e47f6ec25ffb2981db4a |
File details
Details for the file geonamescache-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: geonamescache-1.3.0-py3-none-any.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efa1dd28a87632303c5d882cc52718f04cf28e85f1cc7d6afdf8a6ba7c5ab1dc |
|
MD5 | 5b36ee2ca6faea479df1c79dd6d56c53 |
|
BLAKE2b-256 | 3aeaab8043d4ab7f4041091a6c5070828394d31faae3c871fc9398538f060f2f |