Giter Club home page Giter Club logo

d4v1-sudo / geolocation-geonames.txt-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 22 KB

X,Y → 🗺️ - Python API to get nearest locations (Country, State, City, Road...) and more of a coordinate or informations about all results that includes the searched string using a Geonames txt file as database.

License: MIT License

Python 100.00%
geolocation geolocation-api geonames-api gps gps-coordinates latitude-and-longitude latitude-longitude latitude-longitude-finder trilateration

geolocation-geonames.txt-api's Introduction

X,Y → 🗺️ - Geolocation-geonames.txt-API

This repository contains a set of Python scripts designed to facilitate the retrieval of geographic location information based on various parameters such as latitude and longitude coordinates, city names, country names, and state names.

Scripts

gps.py

This script provides a comprehensive functionality to locate the nearest geographic locations based on given latitude and longitude coordinates (in decimal format). It calculates distances to the closest populated place, road/railway, hill/mountain, lake, park, and building. Additionally, it can determine the nearest administrative location (e.g., city, state) based on the provided coordinates.

get_all_states-codes.py

This utility script extracts state information from geonames data and generates a Python file named all_states_code.py. It is employed internally by gps.py, city-gps-location.py and state-gps-location.py to retrieve corresponding name of a state based on its code.

city-gps-location.py

This script enables users to find the coordinates of a specific city based on its name. It leverages geonames data to perform the city search.

state-gps-location.py

This script enables users to find the coordinates of a specific state based on its name.

country-gps-location.py

Users can utilize this script to find the coordinates of a specific country (it makes more sense using allCountries.txt of Geonames).

all.py

To search for anything in the database, use the following input format: x,y for coordinates (in decimal format) or 'Any string' for a string. If you search for a coordinate, the script will retrieve the nearest coordinate's location and its information. If the search is for a string, the script will retrieve all locations and their information from the database that contain this searched string.

convert.py

This code provides functions to convert between decimal and sexagesimal representations of geographic coordinates (latitude and longitude).

To use it correctly:

  1. Run the script. python3 convert.py <-1 for decimal to sexagesimal or -2 for sexagesimal to decimal>
  2. Follow the prompts:
    • For decimal to sexagesimal conversion, input latitude and longitude in decimal format (In the Southern hemisphere, use negative values for latitude, and in the Western hemisphere, use negative values for longitude). Example: -15.7373 than 36.7289
    • For sexagesimal to decimal conversion, input latitude and longitude in the specified sexagesimal format (N/S for latitude, and E/W for longitude). Example: 39º 42' 17'' N than 22º 49' 52'' E
  3. The script will output the converted coordinates.

Usage

  1. Ensure that you have Python 3.x installed on your system.
  2. Download the geonames text files from Geonames and place them in the repository directory, and change the .txt name file for your own country .txt database in each code you will use.
  3. Run the desired Python script according to your location search requirements. python3 <file.py>

Requirements

  • Python 3.x
  • Geonames text files (downloaded from the Geonames website)

Contributors

  • [d4v1-sudo]

Notes

  • Remember, to use geographic coordinates in these python codes, decimal format is required. I made convert.py precisely for type compatibility issues, as my codes do not accept the sexagesimal system (XXº XX' XX'' N/S/E/W). Then use convert.py for testing and conversions.

  • Feel free to contribute to this project by adding new features, fixing bugs, improving documentation, or addressing issues. Your contributions are highly appreciated!

  • If you have any questions or suggestions, please don't hesitate to reach out.

geolocation-geonames.txt-api's People

Contributors

d4v1-sudo avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

wx4cb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.