Skip to content

Instantly share code, notes, and snippets.

@h1code2
Created July 9, 2021 02:27
Show Gist options
  • Select an option

  • Save h1code2/0edbab500f4fb73e26981e5c68c5214a to your computer and use it in GitHub Desktop.

Select an option

Save h1code2/0edbab500f4fb73e26981e5c68c5214a to your computer and use it in GitHub Desktop.

Revisions

  1. h1code2 created this gist Jul 9, 2021.
    31 changes: 31 additions & 0 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time : 2021/6/30 16:13
    # @Author : h1code2
    # @File : code.py
    # @Software: PyCharm

    # import module
    from geopy.geocoders import Nominatim

    # initialize Nominatim API
    geo_locator = Nominatim(user_agent="GoSpider")

    # Latitude & Longitude input
    Latitude = "25.124398793756"
    Longitude = "62.326154919175"

    location = geo_locator.reverse(Latitude + "," + Longitude, language="en")

    address = location.raw['address']

    # traverse the data
    city = address.get('city', '')
    state = address.get('state', '')
    country = address.get('country', '')
    code = address.get('country_code')
    zipcode = address.get('postcode')
    print('City : ', city)
    print('State : ', state)
    print('Country : ', country)
    print('Zip Code : ', zipcode)