Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ijsbol/pygeolocate
Get a countries geolocation from its name / country code.
https://github.com/ijsbol/pygeolocate
geolocation geolocation-api python
Last synced: 2 days ago
JSON representation
Get a countries geolocation from its name / country code.
- Host: GitHub
- URL: https://github.com/ijsbol/pygeolocate
- Owner: ijsbol
- License: mit
- Created: 2023-02-18T17:30:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T13:46:13.000Z (about 1 year ago)
- Last Synced: 2025-01-01T00:25:51.503Z (8 days ago)
- Topics: geolocation, geolocation-api, python
- Language: Python
- Homepage: https://git.uwu.gal/pygeolocate
- Size: 81.1 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# pygeolocate
`pip install -U pygeolocate` or `python -m pip install -U pygeolocate`
| | |
|--|--|
| |
|## What is pygeolocate?
Pygeolocate is a simple Python module that allows for developers to get the longitude and latitude coordinates of the geographical center of a country based on Googles dataset.Pygeolocate also allows for developers to search for countries based on their country code (and vice versa) as well as search for partial country names.
## Get a country by its full name
```python
# pygeolocate/examples/get_country_by_full_name.py
import pygeolocateunited_kingdom = pygeolocate.locate_by_name("united kingdom")[0]
print(united_kingdom)
print(united_kingdom.name)
print(united_kingdom.coordinates)
print(united_kingdom.coordinates[0])
print(united_kingdom.coordinates['long'])
```## Get a country by part of its name
```python
# pygeolocate/examples/get_country_by_partial_name.pyimport pygeolocate
for country in pygeolocate.locate_by_name("united"):
print(country)
print(country.name)
print(country.coordinates)
print(country.coordinates[0])
print(country.coordinates['long'])
```