What is a spatial database?
A normal database stores information. A spatial database stores information with a geographic component: points, lines, polygons, raster data, coordinates and spatial relationships. It can also run spatial operations on them.
Normal vs spatial database
A normal customer database might store customer, city and revenue. A spatial database can also store actual geographic locations, so you can ask which customers are within 10 km of a store, or which fall inside a service area.
What a spatial database can do
Depending on the database and its extensions:
- Intersections
- Distance calculations
- Buffering
- Spatial joins
- Nearest-neighbour searches
- Containment queries
Spatial databases pay off when geographic data grows too large or complex for simple file-based workflows.
What is spatial indexing?
Say a GIS database holds 10 million buildings and you ask for all buildings within 1 km of a location. Without an efficient way to search, the database may have to examine an enormous number of features.
A spatial index is a data structure that helps a database find features by location more efficiently. It works like a library: instead of checking every book, you narrow the search with sections, shelves and categories.
Why it matters
Spatial indexing becomes important with millions of building footprints, road networks, parcel datasets, GPS points and satellite-derived features. It speeds up:
- Spatial queries
- Intersections
- Nearest-neighbour searches
- Bounding-box searches
Databases such as PostGIS support spatial indexes, which is one reason spatial databases can handle large geographic datasets.
What is PostGIS?
PostGIS is a spatial extension for PostgreSQL. PostgreSQL plus PostGIS gives you a database that can work with spatial data.
What PostGIS can store
PostGIS stores points, lines, polygons, multi-geometries and geographic coordinates, and it supports a large collection of spatial functions. You can ask:
- Which buildings intersect this flood zone?
- Which stores are within 5 km of this road?
- What is the distance between these two locations?
Why use PostGIS
For very large datasets, a spatial database gives you:
- Centralized storage
- Spatial indexing
- SQL queries
- Multi-user access
- Efficient spatial operations
- Integration with GIS applications
PostGIS works well with QGIS: you can store data in PostgreSQL/PostGIS and visualize or edit it from QGIS.
Popular tools
You do not need all of these to start.
| Name | What it is | Good for |
|---|---|---|
| PostGIS | Spatial extension for PostgreSQL | Storing and querying large spatial datasets |
| QGIS | Free, open-source desktop GIS | Visualizing and editing PostGIS data |
| pgAdmin | Open-source administration tool for PostgreSQL | Managing the PostgreSQL database behind PostGIS |
Glossary
| Term | Meaning |
|---|---|
| Spatial database | A database that stores and queries geographic data |
| Spatial index | A structure that helps find features by location quickly |
| Spatial join | Combining tables based on how their features relate in space |
| Buffer | An area drawn at a set distance around a feature |
| Nearest-neighbour search | Finding the closest features to a location |
| PostGIS | A spatial extension for PostgreSQL |
Test yourself
Try to answer each question before opening the answer.
1. What can a spatial database do that a normal database cannot?
It stores geographic locations and relationships, and it can run spatial operations such as intersections, distance calculations, buffering and spatial joins.
2. What problem does a spatial index solve?
Without one, a database may have to examine an enormous number of features to answer a location query. An index narrows the search.
3. What is PostGIS?
A spatial extension for PostgreSQL that adds spatial data types and functions.
4. Name three operations a spatial database can run.
For example intersections, distance calculations, buffering, spatial joins, nearest-neighbour searches or containment queries.
5. How does PostGIS work with QGIS?
You can store data in PostgreSQL/PostGIS and visualize or edit it from QGIS.
6. When does a spatial database pay off compared with file-based workflows?
When geographic data grows too large or complex for simple file-based workflows.
Quick quiz
Pick an answer for each question to see if you got it right.

