GeoGPT is an application that provides the latitude, longitude, and timezone for any address in the world for cities with more than 500 residents. It leverages OpenAI's GPT models to interpret and standardize addresses. Data from geonames.org is then utilized to furnish latitude, longitude, and timezone details.
-
Dependencies
Install the required dependencies using
poetry
:poetry install
-
API Key
Create a
.env
file and set your OpenAI API key within it:OPENAI_API_KEY=your_key_here
-
Create geonames.sqlite3 SQLite3 database
Fetch the
cities500.txt
file from Geoname at this link, which provides details of all cities with a population greater than 500.- Open the SQLite shell:
sqlite3 geonames.sqlite3
- Create the
geoname
SQL table:CREATE TABLE geoname ( geonameid INTEGER PRIMARY KEY, name TEXT, asciiname TEXT, alternatenames TEXT, latitude REAL, longitude REAL, feature_class TEXT, feature_code TEXT, country_code TEXT, cc2 TEXT, admin1_code TEXT, admin2_code TEXT, admin3_code TEXT, admin4_code TEXT, population INTEGER, elevation INTEGER, dem INTEGER, timezone TEXT, modification_date TEXT );
- Set the field separator:
.separator "\t"
- Import the
cities500.txt
file into thegeoname
table:.import cities500.txt geoname
- Open the SQLite shell:
-
Running the Application
Execute the FastAPI application using
uvicorn
:poetry run uvicorn geogpt.main:app --reload
Submit an address to the endpoint, and the application will return details about the location, including its normalized name, country, longitude, latitude, and timezone.
Contributions are welcome! Please fork the repository and open a pull request with your changes. Alternatively, open an issue to discuss suggestions or report bugs.