← All articles

By · · Updated

Can LLMs Do GIS? What ChatGPT-Style Models Get Right, Where They Fail, and the Pattern That Works

Can ChatGPT do GIS? LLMs parse requests and write code well, but a common lat/lon distance shortcut is 59% off east-west in Calgary. The pattern that works.

Can ChatGPT do GIS? Partly. Large language models are good at the language side of GIS: understanding a request, choosing a method, writing PostGIS or GeoPandas code and explaining results. They are poor at geometry done in their heads, and the code they write can take shortcuts: treating latitude and longitude as a flat grid overstates east-west distances by 10% in Karachi and 59% in Calgary. The pattern that works confines the model to classifying the task and extracting parameters through schema-validated function calls, and runs every distance, data fetch and optimisation in deterministic tools after the user confirms.

Update, 30 October 2026: the facility location pattern in this article is now published. SOCA: A Conversational Agent for Facility Location Problems (Cho and Imran, ISPRS International Journal of Geo-Information 15(11), 494) confines the LLM to classifying the formulation and extracting scalar parameters through schema-validated function calls, and hands study area resolution, open-data acquisition, distance computation and exact solution of P-Median, P-Center, MCLP and LSCP to deterministic tools. Every specification is confirmed by the user before solving, and the solutions matched the spopt reference optima on all four models. The code is on GitHub.

This article covers what LLMs do well in GIS work, where they fail (with failures I computed), the architecture I use to get reliable results, the main use cases, published work worth knowing, and a checklist for evaluating any LLM GIS tool.

What are LLMs good at in GIS work?

LLMs are good at tasks where the input and output are language or code, and a person or a program can check the result. In GIS that covers a lot of the day:

All of these share one property: the model produces words or code, and the numbers come from running something.

Where do LLMs fail at GIS?

LLMs fail when they have to do spatial arithmetic in text or vouch for data. The main failure modes:

  1. Distance and area by inspection. Asked how far apart two coordinates are, a model predicts a plausible number. It may be close for famous city pairs it has seen and wrong for the rest.
  2. Coordinate arithmetic shortcuts in code. Treating degrees as metres, or degrees times 111 km as a flat grid, is quick, common in scripts and wrong away from the equator.
  3. Axis order and CRS. Latitude-longitude versus longitude-latitude, and geographic versus projected coordinates, are easy to swap silently.
  4. Raw geometry. Writing out polygon coordinates, buffering by hand or judging whether a point is inside a shape from its coordinates.
  5. Invented data. Dataset names, URLs, field names and statistics that sound right and do not exist.

The second one is the easiest to show with numbers, so I computed it. I took a true 10 km trip from six city centres on three bearings, worked out the end point on the WGS 84 ellipsoid with pyproj's Geod, and then measured the same trip with the shortcut sqrt(dlat² + dlon²) × 111.32 km.

CityLatitudeNorth-south tripDiagonal (45°)East-west tripArea of a 0.01° cell
Karachi24.9°N+0.5%+5.4%+10.1%+10.7%
Bahawalpur29.4°N+0.4%+7.8%+14.7%+15.2%
Islamabad33.7°N+0.4%+10.7%+20.1%+20.5%
Toronto43.7°N+0.2%+20.6%+38.0%+38.3%
Calgary51.0°N+0.1%+32.8%+58.8%+58.9%
Edmonton53.6°N0.0%+38.4%+68.0%+68.0%

A degree of longitude shrinks with the cosine of latitude, and the shortcut ignores that. For comparison, the haversine formula on a sphere stays within 0.4% of the ellipsoid in every case above. It is the same root cause as the Web Mercator distance error, this time arriving through code.

The error carries straight into analysis. Using the three optimal Calgary station sites and the Kontur population hexagons behind my Site Selection Showdown, I counted residents within 3 km of any site:

Left: line chart of how much the degrees-times-111-km shortcut overstates a 10 km trip by bearing, rising from near zero north-south to 10% east-west in Karachi, 20% in Islamabad, 38% in Toronto and 59% in Calgary, with haversine near zero. Right: map of Calgary hexagons with three sites, true 3 km circles in dashed black and the narrower shortcut ellipses in red

The shortcut is nearly right north-south and badly wrong east-west. In Calgary it drops 55,312 residents from a 3 km coverage count.

Axis order fails more dramatically. Swap Karachi's coordinates and the point (67.01°N, 24.86°E) lands in Finnish Lapland, 5,504 km away. Swap Islamabad's and it lands in the Barents Sea, 4,910 km away. Calgary's swap fails loudly, because −114° is not a valid latitude, which makes it the lucky case.

The fix in code is short. Ask for it explicitly, and check that the code you get looks like this:

from pyproj import Geod
geod = Geod(ellps="WGS84")

# Wrong away from the equator: degrees treated as a flat grid
km_bad = ((lat2 - lat1) ** 2 + (lon2 - lon1) ** 2) ** 0.5 * 111.32

# Right: geodesic distance on the WGS 84 ellipsoid (note lon, lat order)
_, _, metres = geod.inv(lon1, lat1, lon2, lat2)
-- PostGIS: residents within 3,000 metres of any site, on the geography type
SELECT SUM(d.pop) AS covered
FROM demand d
WHERE EXISTS (
  SELECT 1 FROM sites s
  WHERE ST_DWithin(d.geom::geography, s.geom::geography, 3000)
);

ST_DWithin on geography takes its distance in metres. On geometry in EPSG:4326 it takes degrees, which is the same trap in SQL.

What does "LLM parses, tools compute" look like?

The reliable pattern gives the language model two jobs, reading the request and writing the explanation, and gives every number to code. In a facility location agent the flow is:

  1. Request. "Where should 5 fire stations go in Calgary to reach the most people within 4 minutes?"
  2. Classify and extract. The model calls a function with typed arguments: the formulation (MCLP), the number of facilities (5), the service standard (4 minutes) and the place name.
  3. Schema check. Code validates the call. An unknown model name, a negative facility count or a missing parameter goes back to the model with the error.
  4. Confirm. The user sees the specification in plain terms and approves or edits it. Nothing runs before this.
  5. Deterministic tools. A geocoder resolves the boundary, data tools fetch population, roads and candidate sites, a network tool computes travel times, and an exact solver finds the optimum.
  6. Explain. The model writes the summary from the results table and quotes its numbers exactly.

Diagram of the LLM parses, tools compute pattern: a request goes to a red LLM step that classifies the problem and extracts parameters, then a grey schema check that loops back on invalid arguments, a user confirmation step, grey deterministic tools, results, and a final red LLM step that explains the results

Two model calls, both on text. Coordinates, travel times and the optimum all come from code.

The function schema is where the design lives. The model chooses among named options and fills bounded fields, and nothing in it accepts a coordinate:

from typing import Literal
from pydantic import BaseModel, ConfigDict, Field

class FacilityLocationSpec(BaseModel):
    model_config = ConfigDict(extra="forbid")
    formulation: Literal["p_median", "p_center", "mclp", "lscp"]
    place_name: str = Field(description="Resolved to a boundary by a geocoding tool")
    facilities: int | None = Field(None, ge=1, le=200, description="Required for p_median, p_center, mclp")
    service_standard_min: float | None = Field(None, gt=0, le=60, description="Required for mclp, lscp")
    travel_mode: Literal["drive", "walk"] = "drive"
    demand: Literal["population"] = "population"

The confirmation step matters as much as the schema. "Five stations within 4 minutes" can mean maximal covering or a p-median with a 4-minute cap, and only the user knows which. If you want to see how much the choice of standard and station count changes the answer, the coverage curve article shows it for three cities.

Which GIS tasks are worth giving to an LLM?

The tasks worth giving to an LLM are the ones where its output is code or labels that a tool runs or a reference list checks.

Use caseWhat the LLM doesWhat the tools doCheck before trusting
Natural language to SQL or PostGISWrites the query from the schemaDatabase runs itRead the query; geography vs geometry; row counts
GeoPandas or ArcPy scriptsWrites the scriptPython runs itCRS before any .area, .buffer or distance
Metadata and documentationDrafts descriptions from the schemaNoneA person reviews it
Classifying features by text attributesMaps text to a code listValidator checks codesConfusion matrix on a labelled sample
Address cleanupParses the residue rules missRules, geocoder, validatorHold-out match and false-match rates
Location-allocation agentsClassifies the problem, extracts parametersData, travel times, exact solverUser confirms the specification

Address cleanup gets its own walkthrough in cleaning address data before geocoding, with the schema and validation gate. The same idea runs through every row: the model's output goes into something that can reject it.

What published work exists on LLMs for GIS?

Three lines of work are worth knowing, and all of them put tools or code between the model and the answer.

Code-generating agents like LLM-Geo are flexible, because they can attempt any task Python can express. The cost is that each run writes new code, which is where shortcuts like the one above come from. Tool-calling agents with fixed, tested tools are narrower and more repeatable. For decisions such as where to put a station, I prefer the second.

How should you evaluate an LLM GIS tool?

Evaluate it with tasks whose answers you already know, and check where each number came from. A checklist:

  1. Known distance. Ask for the distance between two points at your latitude and compare with a geodesic calculation.
  2. Known area. Give it a polygon with a published area, such as a city boundary.
  3. High-latitude buffer. Ask for a 3 km buffer in Calgary or Edmonton and measure its east-west width.
  4. Swapped coordinates. Supply a point in latitude-longitude order without saying so, and see whether it notices.
  5. Data provenance. Every dataset should be named, versioned and linked, and the links should resolve.
  6. Tool trace. You should be able to see each tool call and its arguments, or the generated code, and rerun it.
  7. CRS stated. The tool should say which CRS each measurement used.
  8. Numbers from tools. Figures in the summary should match the tool output exactly.
  9. Confirmation before compute. It should show you the parsed specification before running anything slow or costly.
  10. Repeatability. The same request twice should give the same specification and the same result.

A tool that passes 1 to 4 because its tools compute and fails 5 to 10 is still risky, because you cannot audit it.

What should you take from this?

LLMs can do the parts of GIS that are language: understanding a request, choosing the method, writing the code and explaining the result. They should not be trusted to compute geometry, and code they write should be checked for the degree shortcut, axis order and CRS. The reliable design limits the model to classification and parameter extraction through schema-checked function calls, runs every measurement and optimisation in deterministic tools, and asks the user to confirm before solving. That design is what SOCA implements for facility location, and it carries over to address cleaning, query writing and most other GIS tasks.

If you want an LLM-assisted GIS workflow built or an existing one audited, email me at mahad.imran29@gmail.com.

Frequently asked questions

Can ChatGPT do GIS analysis?

It can do the language parts well: turning a request into a method, writing PostGIS, GeoPandas or ArcPy code, explaining results and drafting metadata. It is unreliable at anything it would have to compute in its head, such as distances, areas or coordinates, and it can describe datasets that do not exist. Use it to write and run code against real data, then check the output.

Can an LLM calculate distances from latitude and longitude?

Not reliably by itself, and code it writes can take shortcuts. Treating degrees as a flat grid and multiplying by 111 km overstates an east-west distance by 10% in Karachi and 59% in Calgary, by my calculation with pyproj. Ask for geodesic distance with pyproj, or PostGIS geography, and test the code on a pair of points with a known distance.

What is an AI agent for GIS?

It is a system in which a language model reads a request, decides which GIS tools to call and with what parameters, and reports the result. The reliable designs restrict the model to choosing tools and filling typed parameters, run all geometry, data access and optimisation in ordinary code, validate every tool call against a schema and ask the user to confirm before anything expensive runs.

Can an LLM solve a facility location problem?

It should not solve one directly, because the answer depends on exact distances and an optimisation search the model cannot do in text. It can classify the problem (p-median, p-center, maximal covering or set covering) and extract parameters such as the number of sites and the time standard. A solver then finds the optimum on real travel times, as in the SOCA system.

How do I evaluate an LLM tool for GIS work?

Give it test tasks with known answers: a distance between two cities, an area of a known polygon, a buffer at high latitude, a request with lat/lon swapped. Check whether numbers come from tools or from the model's text, whether data sources are real and cited, whether it states the CRS, and whether you can see and rerun the code or tool calls behind every result.

Let's talk.

Best way to reach me is email. I respond to most things.