Spatial Data Models: Vector vs Raster & Spatial Databases (PostGIS)
Idea in plain words
Spatial Data (where features are located on Earth) vs Attribute Data (descriptive characteristics stored in tabular form).
Exam tip
High-yield exam topic (Very High).
Explanation
Choosing between vector and raster representation depends on the nature of the geographic phenomenon. Discrete features with crisp boundaries (such as cadastral land parcels or sewer pipes) are naturally represented as vectors, preserving precise perimeter and topological relationships without pixelation. Continuous geographic fields that vary continuously across space (such as elevation, rainfall, and land surface temperature) are represented as rasters. Spatial databases utilize R-Tree and GiST indexing to accelerate bounding-box queries over millions of spatial polygons.
Key points
- Vector Data Model: Represents features using discrete geometric primitives: Points (trees, wells), Lines (roads, rivers), Polygons (land parcels, lakes).
- Raster Data Model: Represents continuous surfaces using a regular grid of square cells/pixels, each containing a single attribute value (elevation, temperature, satellite imagery).
- Resolution in Raster: Spatial resolution determined by cell size (e.g., 30m Landsat cell vs 10m Sentinel-2 cell).
- Spatial Database Management Systems (Spatial DBMS): Extensions like PostGIS (for PostgreSQL) adding native geometry data types (GEOMETRY, GEOGRAPHY) and spatial SQL indexes (R-Tree / GiST).
Example
Example
Digital Elevation Model (DEM) is a raster dataset where each cell value represents ground elevation in meters above mean sea level.
Code examples
-- Spatial SQL Query in PostGIS
-- Find all health posts within a 5 km buffer of a flood-inundated zone
SELECT h.name, h.ward_number
FROM health_posts h, flood_zones f
WHERE f.risk_level = 'High'
AND ST_DWithin(h.geom, f.geom, 5000); -- 5000 meters buffer query
Exam questions
- [10 Marks] Compare Vector and Raster data models across structure, storage requirements, spatial precision, and analysis capabilities.
- [6 Marks] What is a Spatial DBMS? Explain the role of PostGIS and spatial indexing (GiST / R-Tree) in spatial queries.