1
This section covers OODBMS and ORDBMS, spatial data types and models, operations on spatial data, spatial joining and indexing, spatial data mining, spatial query language, OGIS standards, the basics of PostgreSQL and PostGIS, and spatial storage and access.
2
OODBMS and ORDBMS • An object-oriented DBMS stores objects with their attributes and methods, supporting classes, inheritance, encapsulation and complex objects — attractive for spatial and CAD data, but with limited standardisation and market support. • An object-relational DBMS keeps the proven relational engine and SQL but allows user-defined data types and functions.
3
This is how spatial support is implemented today: the geometry is a column type with its own operators, indexes and functions.
4
PostgreSQL/PostGIS, Oracle Spatial, SQL Server Spatial, SpatiaLite (SQLite).
5
Spatial Data Types and Models • The OGC Simple Feature model defines a geometry hierarchy:
6
Geometry → Point, LineString, Polygon and the collections MultiPoint, MultiLineString, MultiPolygon, GeometryCollection (with curves and surfaces in the extended model).
7
Each geometry carries an SRID identifying its coordinate reference system, and is exchanged as WKT (e.g., POINT(85.32 27.71)) or the binary WKB. • Two complementary views of space: the object (feature/entity) view — discrete objects with geometry and attributes (parcels, roads); and the field view — continuous variation over space, stored as rasters or coverages (elevation, temperature).
8
A topological model additionally stores the shared nodes, edges and faces so that adjacency and connectivity are explicit and geometry is not duplicated.
9
Operations on Spatial Data Group Examples (PostGIS names) Properties and constructors STArea, STLength, STPerimeter, STCentroid, STEnvelope, STBuffer, STConvexHull, STSimplify, STTransform (change CRS), STIsValid Topological relationships (predicates) STIntersects, STContains, STWithin, STTouches, STCrosses, STOverlaps, STDisjoint, STEquals — formally defined by the DE-9IM (dimensionally extended nine-intersection model) Set (overlay) operations STUnion, STIntersection, STDifference, STSymDifference — the database equivalents of GIS overlay Measurement and proximity STDistance, STDWithin (within a given distance — index-assisted), STClosestPoint, nearest-neighbour ordering with the <-> operator Aggregation and output STCollect, STUnion (aggregate), STₐₛₜₑₓₜ, STAsGeoJSON, STAsMVT for web tiles Spatial Join and Spatial Indexing • A spatial join combines two tables using a spatial relationship instead of a common key — for example, assigning each well to the ward polygon that contains it:
10
SELECT w.id, p.ward FROM well w JOIN ward p ON STWithin(w.geom, p.geom);
11
It is computationally expensive and depends entirely on indexing. • Spatial indexing: ordinary B-tree indexes cannot order two-dimensional data, so spatial DBMSs use R-trees (and R*-trees) — hierarchies of minimum bounding rectangles (MBR) — or quadtrees, grid indexes, k-d trees and space-filling curves (Hilbert, Morton/geohash).
12
PostGIS implements the R-tree over the generalised GiST index. • Queries are answered by a filter-and-refine strategy: the index quickly returns candidates whose bounding boxes satisfy the condition (the cheap filter step), and the exact geometric test is applied only to those candidates (the expensive refine step).
13
Without a spatial index, a spatial join degenerates into comparing every pair of geometries.
14
Spatial Data Mining and Query Language • Spatial data mining extracts previously unknown and useful patterns from spatial data, taking account of spatial dependence — Tobler's first law of geography: 'everything is related to everything else, but near things are more related than distant things'.
15
Techniques: spatial clustering (K-means, DBSCAN for arbitrary shapes and noise), spatial autocorrelation (Moran's I), hot-spot analysis (Getis-Ord Gi*), spatial association rules and co-location patterns, classification and prediction, outlier detection, and trajectory/movement mining.
16
Applications: crime and disease clusters, landslide and flood susceptibility, market analysis, transport patterns. • The spatial query language is SQL extended with the spatial types and functions above, standardised by OGC Simple Feature Access — SQL (the 'OGIS' standards) and ISO SQL/MM Spatial, which prescribe the ST_ prefix and the behaviour of each function, so that queries are portable between compliant systems.
17
PostgreSQL/PostGIS and Spatial Storage • PostgreSQL is a free, open-source, standards-compliant object-relational DBMS;
18
PostGIS is its spatial extension, enabled with CREATE EXTENSION postgis;.
19
It provides the geometry type (planar, fast) and geography type (on the ellipsoid, for global data), the spatialrefsys table of coordinate systems, raster support, topology and pgRouting for network analysis. • Typical workflow: create the database and extension → load data with shp2pgsql, ogr2ogr or QGIS → create a GiST index (CREATE INDEX idx ON parcel USING GIST (geom);) → run spatial SQL → publish through GeoServer/QGIS Server as OGC services (Chapter 6.5 and 8.6). • Spatial storage and access: geometries are stored in compact binary form (large objects are compressed and moved out of line), tables may be clustered on the spatial index or partitioned by area or time, rasters are stored as tiles with overviews/pyramids, and caching or materialised views speed up repeated queries.
20
Access is through SQL (psql, ODBC/JDBC, Python), GIS desktop clients and web services, with the usual database facilities for multi-user editing, transactions, versioning, privileges and backup.