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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygeocity-0.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.tar.gz
Algorithm Hash digest
SHA256 e600bb034d717cd5cf00b5cc758bb7d531decf87bb9087aabc52d4fad46bfeeb
MD5 65e064460f72f9b8695ba3c8b1433286
BLAKE2b-256 92310094356c80b1b4a1728bfa678845863b3c68f7f4baf1b8092d3c8e99d547

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygeocity-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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-py3-none-any.whl
Algorithm Hash digest
SHA256 5bd40daa25536226f2481361d3838c5adba5e28527928fba2f9c52143c7f0735
MD5 68fc0e3cc0c809b86dc5ba55c8c54129
BLAKE2b-256 a2b785d68721b73f73b3de02bf342349b2f685458e0c4cb093e0fc766eb4d0cd

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