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

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

Warning: package data is not yet uploaded correctly, can not install with pip.

pip install pygeocity
pip3 install pygeocity

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.1.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.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygeocity-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 69b159d6b92654773c98fdc924c0fc1f9c42e4ef548f9f20dd1b055fe130609b
MD5 689c500bc082e76391548b3e0169bcc6
BLAKE2b-256 ba83c8a9ef46d6041fb2a41f60e9976f0f62dff93e251e10a4e76efbe8dffd79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygeocity-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2125c53948340031aeb0b3d3b6b88f79e034e452b81c0801b115d05f27b556c7
MD5 48529e22e2f59d19b75bd826da33fe50
BLAKE2b-256 7e8570c315dd34787cd8a9461de622fe0891b65751d36ed95b35e4e42b70a13b

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