Skip to main content

This package will take a latitude and longitude coordinate which will return the country, city name, alternate name(s), population, timezone, and exact coordinates of the city.

Project description

GeoNames - Find City Name with Population > 1000

Opendatasoft has as a dataset from GeoNames which contains all cities with a population greater than a thousand people. This dataset will be used to create a reverse geocode function, called search. This project has been inspired by Richard Penman's reverse-geocode project. Like Richard Penman's approach, I too am using a k-d tree which is implemented using the SciPy library.

This package will take a latitude and longitude coordinate which will return the country, city name, alternate name(s), population, timezone, and exact coordinates of the city.

Dependencies

  • Python 3.11.4
  • Pandas 2.0.3
  • SciPy 1.11.1

Example usage:

This package only has one function search and it has a single parameter coordinate.

Enter latitude and longitude into the search function, as a list, to get your results.

>>> import geonames
>>> geonames.search([11.85812, -86.23922])

Outputs:
    {
        0: 3620170,
        1: 'Diriamba',
        2: 'Diriamba',
        3: 'Diriamba,Diriambo',
        4: 'NI',
        5: 'Nicaragua',
        6: 35008,
        7: 'America/Managua',
        8: '2018-08-08',
        9: 'Nicaragua',
        10: '11.85812, -86.23922',
        11: ' -86.23922',
        12: '11.85812'
    }

One can also enter a list of multiple latitudes and longitudes into the search function to get your results.

>>> geonames.search([[11.85812, -86.23922],[12.4825, -87.17304]])

Outputs:
    {
        'Geoname ID': {0: 3620170, 1: 3620269},
        'Name': {0: 'Diriamba', 1: 'Corinto'},
        'ASCII Name': {0: 'Diriamba', 1: 'Corinto'},
        'Alternate Names': {0: 'Diriamba,Diriambo', 1: 'Corinto'},
        'Country Code': {0: 'NI', 1: 'NI'},
        'Country name EN': {0: 'Nicaragua', 1: 'Nicaragua'},
        'Population': {0: 35008, 1: 19183},
        'Timezone': {0: 'America/Managua', 1: 'America/Managua'},
        'Modification date': {0: '2018-08-08', 1: '2018-08-08'},
        'LABEL EN': {0: 'Nicaragua', 1: 'Nicaragua'},
        'Coordinates': {0: '11.85812, -86.23922', 1: '12.4825, -87.17304'},
        'Longitude': {0: ' -86.23922', 1: ' -87.17304'},
        'Latitude': {0: '11.85812', 1: '12.4825'}
    }

Install

pip install pygeocity
pip3 install pygeocity

Make sure you install version 0.1.3

Use:

pip install pygeocity==0.1.3

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

pygeocity-0.1.3.tar.gz (9.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygeocity-0.1.3-py3-none-any.whl (9.8 MB view details)

Uploaded Python 3

File details

Details for the file pygeocity-0.1.3.tar.gz.

File metadata

  • Download URL: pygeocity-0.1.3.tar.gz
  • Upload date:
  • Size: 9.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pygeocity-0.1.3.tar.gz
Algorithm Hash digest
SHA256 60c41666b12e516ed257f92c4bb38634af341db76151f0e23de9ab460a7abb0a
MD5 8b5c3735532ed141e9fe79e1a3d5565d
BLAKE2b-256 c5cb6840f4be8c559587c618c96e64cbc9152c28916ca04984263bd10872232f

See more details on using hashes here.

File details

Details for the file pygeocity-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pygeocity-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pygeocity-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c05f713367e9f68797c3368307863dcae2a715748d358fc87981a0d353c9b19
MD5 c08bd98f932ba6a189b4527531a2fcc7
BLAKE2b-256 d13ba803f7472bcdae1bfbbc47a80bc97f991a1a0e4bef876625b1659aa98d63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page