Gains:
- Ability to design GIS analyzes such as buffer, intersection, spatial combination and neighborhood with AI and construct them step by step
- Ability to generate attribute and spatial queries (SQL/expression) from natural language and adapt them to the QGIS/PostGIS environment
- Ability to verify GIS analysis output with topological consistency, projection suitability and area/length logic
GIS (Geographic Information System; GIS in English) is the general name of systems that store, query, analyze and map location data. Most of the survey engineer's daily work takes place here: "Which parcels are closer than 50 meters to this stream?", "Where are the areas where these two layers overlap?", "How many buildings per neighborhood?" Producing answers to questions such as using spatial analysis. In this unit, we cover how to use artificial intelligence to design these analyses, generate queries from natural language, and adapt them to the QGIS/PostGIS environment. Principle: AI constructs the analysis and writes the query; The validity of the result remains with the engineer through projection, topology and logic control.
Basic terms first. Vector data represents the world with points, lines, and polygons (plots, roads, wells). Raster data represents the world in a grid of cells/pixels (elevation model, satellite image). Attribute is table information related to a geometry (parcel area, owner, island/parcel number). Buffer is the area created at a certain distance around a geometry. Spatial join matches two layers based on spatial relationship (each building with its neighborhood). Topology is the neighborhood/overlap/gap rules between geometries.
The Role of AI in GIS Analysis
AI accelerates GIS in three concrete places:
- Analysis design. "Which layers are processed, in what order, with what tools to answer the question?" It comes up with a step-by-step plan to the question. This reduces the thinking load, especially in complex multi-step analyses.
- Query generation. Translates the natural language request into a QGIS expression, SQL, or PostGIS function. It puts the request "Plots with an area of less than 500 m² and of agricultural nature" into a filter expression.
- Workflow and code generation. It translates iterative analysis into Python/PyQGIS script (we delve deeper into this topic in units 10 and 11).
But AI has a critical blind spot: it doesn't see the data, it just sees your recipe. It doesn't know which CRS the layer is in, the exact name of the attribute column, whether the data is clean or not. Therefore, the query it produces is syntactically correct but may be wrong on your data.
Caution: Distance and area calculations are accurate only on a metric (projected) CRS. Taking a 50 m buffer directly in geographical coordinates (degrees) gives completely inaccurate results due to degree-meter confusion. Put the layer in the appropriate projection before analysis.
Step by Step: Constructing a Spatial Analysis
Sample question: "Find parcels with building permits that are closer than 100 m to a stream."
- Clarify inputs and CRS. Stream layer (line), parcel layer (polygon), both must be in metric CRS (e.g. TUREF/TM33).
- Have the steps planned. To AI: 100 m buffer to stream → intersection/selection with plots → filter “licensed” from attribute → result count. Let it write the sequence and the output of each step.
- Have the query generated. Translate the filter expression ("status" = 'licensed') and selection logic into QGIS/PostGIS.
- Test on small sample. Run the analysis on a small subset rather than the entire data and visually check the result.
- Verify the result. Is the count reasonable (rank)? Are the selected parcels really close to the stream (visual/topological check)? Do the fields make sense?
Three Mini Cases: By the Numbers
Case 1 — Degree bumper disaster. An intern applied a 100 unit buffer directly to the parcel layer in the WGS84 geo CRS; the result produced absurd areas with a radius of approximately 11 km (1 degree ~111 km). The rank check ("buffer area cannot be thousands of times the size of the parcel") showed the error immediately. When the layer was imported into metric CRS, the buffer was correct as 100 m.
Case 2 — Incorrect column name. AI produced the expression "qualified" = 'agriculture' for "parcels qualified for agriculture"; whereas the real name of the column was PLOT_VASF and the value was FIELD. The query returned 0 results without any errors. When the engineer opened the attribute table and gave the actual column name and values to the AI, the query improved. Lesson: AI can make up column names; give the actual schematic.
Case 3 — Topology problem. There were small gaps (slivers) and overlaps in the two neighboring district boundary layers. An AI-powered “area total” analysis deviated from the true total by about 2% due to these errors. After topology control and correction, the areas became consistent. Lesson: the analysis result is only as clean as the input geometry.
Weak Prompt / Strong Prompt
Weak prompt:
Write a query that finds parcels near the stream.
Powerful prompt:
Task: Produce a spatial analysis construct and expression for QGIS. Context:- stream_layer: line, CRS EPSG:5256 (TUREF/TM33)- parcel_layer: polygon, CRS EPSG:5256, attribute columns: ADA_NO, Plot_NO, STATUS (values: 'licensed', 'unlicensed'), AREA_M2Question: Select parcels closer than 100 m to the stream and STATUS = 'licensed', give their number and total area. Requests: 1) Order the steps (buffer -> spatial selection -> attribute filter). 2) Write which tool will be used in each step. 3) Remind me of the metric CRS requirement for distance/area. 4) Verify the result step (rank + visual control). add.
The powerful prompt gives the actual column names, CRS, value set and validation step; The output fits your data.
Four Copiable Templates
1) Creating an analysis plan:
Write a step-by-step GIS workflow to answer the following spatial question: specify the input layer, the tool used, and the output layer at each step. Check the steps that require metric CRS. Question: [question]. Layers: [list]
2) QGIS expression from natural language:
Convert the following filter to a QGIS attribute expression. ONLY use the given columnnames and values; column fitting. Ask if there is uncertainty.Columns/values: [scheme]. Request: [filter]
3) PostGIS query:
Write PostGIS SQL for the following spatial analysis (ST_ functions).Assume SRID [srid] of geometries; The distance must be metric. Explain the query and add a hash query for validation. Analysis: [definition]
4) Result reasonableness check:
Check the following GIS analysis result for reasonableness: result count rank, field/length logic, null/duplicate records, CRS compliance. List the suspicious points and write the possible cause. Result summary: [summary]
GIS Analysis Tools Comparison
vehicle
What does
Typical usage
Attention
Buffer
Distance area around
Guard band, proximity
Metric CRS required
Intersect
Subtracts common area
Conflict analysis
Topology must be clean
Spatial join
Matches by location
Building-neighbourhood relationship
Relationship type (intra/intersecting)
Dissolve (combine)
Fuses the same attributes
Boundary simplification
Attribute selection
Clip
Cuts according to a limit
Workspace limitation
Is the boundary geometry correct?
Common mistakes
- Calculating distance/area in geo CRS. Not switching to metric projection before analysis.
- Using AI-made up column names. Not giving the real scheme; silent 0 results.
- Performing analysis with data with broken topology. Gaps/overlaps result in space and counting errors.
- Confusing the type of spatial relationship. "Inside" and "intersecting" give different results.
- Not subjecting the result to rank control. Not noticing absurd fields/numbers.
- Running blindly through all data. Applying to big data without testing on small sample.
In summary
Artificial intelligence in GIS analysis; It is a powerful assistant for planning workflow, translating natural language request into query and generating code. But AI doesn't see the data; You must provide the CRS, actual column names, and topology quality. The most critical rule is that distance and area calculations are accurate only in metric CRS. Check each result for order, topological consistency, and logic; Do not apply it to big data without testing it on a small sample.
Application task
Select a spatial question (e.g. "buildings less than 25 m from a road"). Type the layers, their CRS, and actual attribute column names. Have AI generate analysis plan and QGIS expression step by step; then test the output with three checks: (1) is the metric CRS used, (2) do the column names match the actual schema, (3) is the number of results reasonable in order.
checklist
- [ ] I imported the layers into metric CRS (for distance/area).
- [ ] I gave the actual attribute column names and values to the AI.
- [ ] I had the analysis steps and tools planned.
- [ ] I have selected the spatial relationship type (within/intersecting) correctly.
- [ ] I checked the topology of the input geometry.
- [ ] I tested the analysis on a small sample first.
- [ ] I checked the result for rank and logic.
- [ ] I kept the final comment for engineer approval.