Skip to main content

Geonames data for continents, cities and US states.

Project description

https://img.shields.io/pypi/v/geonamescache.svg

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

  1. Fork the repository on GitHub

  2. Commit your changes to the develop branch

  3. Write test(s) for any new feature

  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geonamescache-1.3.0.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

geonamescache-1.3.0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

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

Hashes for geonamescache-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5a1fc774a3282d324952b87eb5c2c13684055e68e829526909c76c2fffb84f8f
MD5 6a7117173e855366fa714aba595724be
BLAKE2b-256 716b9190135ee0791d5a876a6117278b965d4e2674e0e47f6ec25ffb2981db4a

See more details on using hashes here.

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

Hashes for geonamescache-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efa1dd28a87632303c5d882cc52718f04cf28e85f1cc7d6afdf8a6ba7c5ab1dc
MD5 5b36ee2ca6faea479df1c79dd6d56c53
BLAKE2b-256 3aeaab8043d4ab7f4041091a6c5070828394d31faae3c871fc9398538f060f2f

See more details on using hashes here.

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