Introduction:
Geospatial analysis is the science of collecting, processing, and interpreting geographic data, and it has become vital across various fields such as urban planning, environmental monitoring, disaster management, and agriculture. Accessing and analyzing geospatial data is made possible through geographic information systems (GIS), integrated programming platforms, cloud computing, and frameworks powered by natural language processing (NLP). However, traditional geospatial analysis tools often pose significant challenges for non-expert users due to their technical complexity and the specialized knowledge required to use them effectively.
For instance, the seemingly simple task of locating nearby schools involves multiple technical steps such as specifying geographic coordinates, defining a search radius, and setting conditions like proximity to parks, transportation services, and traffic flow. In such cases, GIS users typically apply tools like Buffer and Intersect to narrow down results. This process illustrates how difficult it can be for users without GIS expertise to engage with traditional workflows, ultimately limiting the accessibility of these powerful tools to a wider audience.
Related Work
Despite advancements in geospatial technologies and digital platforms, most GIS tools still require technical expertise, making them less accessible to non-experts. Web-based platforms like ArcGIS Online and Google Earth Engine offer powerful capabilities but involve scripting or complex configurations. Recent progress in natural language processing (NLP) using large language models (LLMs) such as GPT-4 has enabled systems to translate user queries into geospatial data requests. However, tools like NLMaps and OSM-GPT often struggle with understanding user intent, particularly in ambiguous or open-ended queries.
Materials and Methods
This study introduces a web-enabled, open-source framework that uses GPT-generated prompts to retrieve geospatial data from OpenStreetMap (OSM). The approach allows users to enter queries in plain language, which are converted into Overpass QL through prompt engineering. The system retrieves and visualizes relevant spatial data with minimal user effort. Built using the React-based Next.js framework, the platform is lightweight, cost-effective, and accessible to users without GIS knowledge.
- Web-Enabled Framework: Designed for simplicity, the framework guides users through selecting an Area of Interest (AOI), entering a natural language query, and receiving mapped results. The input is processed and translated by GPT into a structured query compatible with the Overpass API. This query retrieves data, which is then displayed on an interactive interface. By removing technical barriers, the system democratizes spatial data access and supports decision-making for non-specialist users.
- Components and Modules: The web framework allows users to input queries either in structured Overpass QL or natural language. Natural language queries are processed using GPT-4o, which generates Overpass queries based on selected AOI. The system then retrieves, visualizes, and exports geospatial data from OSM. Core modules include AOI selection, natural language input, prompt-based query generation, and map-based data visualization.
Failure Containment & Iterative Refinement
If a query fails or returns no results, fallback prompts are triggered to guide GPT in generating broader queries. The prompt design includes:
- Prompt Initialization – Starts with user input in natural language.
- Response Format Instruction – Defines the output format using “query_name” and “data.”
- Example Queries – Provides samples to help GPT generate accurate Overpass QL queries.
3.2.3.2 Data Retrieval
- Fetch Request to Overpass API – A POST request is sent with a structured query and geographic bounds.
- Processing the API Response – The returned data is converted to JSON for easy parsing and visualization.
3.2.3.3 Handling and Visualizing Data
The retrieved geospatial features (points, lines, polygons) are displayed as interactive layers on the map. Each layer is uniquely styled and can be customized by users for better clarity and analysis.
Results and Discussion
The web-enabled framework simplifies geospatial data access by allowing users to input natural language queries. These inputs are converted into Overpass QL using GPT-generated prompts and then used to retrieve data from OSM. The interactive map displays results that are highly accurate and customizable, comparable to commercial GIS solutions.
User Specified Query in Natural Language:
“Find all nearby hospitals”
Structured Query generated through GPT:
{
"query_name": "hospitals",
"osmquery": "[out:json][timeout:45];nwr['amenity'='hospital']({{bbox}});out;>;out skel qt;"
}
Results obtained through OSM:
Hospitals near the user's location are displayed as map points. Users can select an AOI, draw bounding boxes, and tailor queries like “Show me the parks within the bounding box” for precise results. Data can be downloaded in GeoJSON format for further GIS use. The framework shows 95% accuracy and supports use cases like green space analysis, urban density evaluation, and transport planning—helping city planners and officials make data-driven decisions.
Model Validation
All experiments were conducted on a Windows 11 system with an i5 processor, 16GB RAM, and no dedicated GPU. The dashboard, GPT-4o integration, and prompt design were developed and tested on this setup. GPT-4o and Overpass API were accessed using free API keys, and no model fine-tuning was necessary, making the system lightweight.
To validate accuracy, a test set of 50 diverse spatial queries was used. Queries were assessed based on their syntactic validity (Overpass QL execution success) and semantic correctness (relevance of results across similar queries), with input from geospatial experts. The framework performed strongly in tasks like PoI and buffer queries but showed slightly reduced precision in complex, multi-condition cases.
Ethical Considerations and Model Bias
The system may reflect inherent biases in GPT-4’s training data, such as overrepresentation of urban features, which can affect spatial accuracy. To mitigate this, prompts were crafted to include clear geographic references, and outputs were manually validated for spatial relevance. All geospatial data is sourced from OpenStreetMap and complies with ODbL licensing.
Discussion and Analysis of Results
The framework simplifies geospatial data retrieval through natural language input, improving accessibility and efficiency. Compared to traditional methods, it delivers higher accuracy, faster execution, and better usability with customizable map views. Some limitations remain, such as reduced accuracy for vague or multi-condition queries and slower responses in dense urban areas. Future improvements may include query chunking, result caching, and smarter prompt handling. Despite these challenges, the system effectively enhances geospatial interaction using AI.
Conclusion:
This study presents a web-enabled framework that uses GPT-4o to convert natural language queries into structured Overpass queries, enabling seamless geospatial data retrieval from OpenStreetMap. By automating the query process, it empowers non-technical users to interact with spatial data efficiently. The system demonstrates high accuracy and faster response times, proving useful in applications such as urban planning and disaster management. While it effectively supports exploratory spatial analysis with customizable map views, limitations remain in handling ambiguous queries and large datasets. Future enhancements will focus on multi-turn query handling, caching, and expanding multilingual capabilities to further improve performance and usability.