Lecture 5: Spatial Data

Spatial Database Systems

J Mwaura

Spatial Database

Spatial database

  • Database systems that are enabled to store & manage geometries as special data types, as well as manipulate spatial objects

Key aspects

  • Spatial data types; point, line, & polygon
  • Spatial indexing - for efficient processing of spatial operations
  • Spatial functions - for querying of spatial properties & relationships

Spatial Data Types

data-modals

Data types: Geometry & Geography

Geometry type represents data in a Euclidean (flat) coordinate system

Geography type represents data in a round-earth coordinate system

  • Point, MultiPoint, LineString,
  • CircularString, MultiLineString, CompoundCurve,
  • Polygon, CurvePolygon, MultiPolygon, and
  • GeometryCollection

Spatial Indexes

Indexes

  • allow fast and random access to subsets of data
  • Indexing for standard types (numbers, strings, dates) is usually done with B-tree indexes
  • A B-tree partitions the data using the natural sort order to put the data into a hierarchical tree

Spatial databases provide a spatial index that instead answers the question

  • which objects are within this particular bounding box?

Bounding Boxes

A bounding box is the smallest rectangle capable of containing a given feature

Spatial Indexes

  • R-tree (used in PostGIS)
  • Quadtrees, and
  • Grid-based indexes

Spatial indexes provide approximate results

Spatial Data Types

data-modals

Spatial Functions

Ordinary functions manipulates data using queries

  • concatenate strings
  • perform hash operations on strings
  • mathematics on numbers
  • extracting information from dates

Spatial database functions

  • analyzing geometric components
  • determining spatial relationships
  • manipulating geometries

Spatial Functions

  • Conversion - between geometries and external data formats
  • Management - manages information about spatial tables and PostGIS administration
  • Retrieval - retrieves properties and measurements of a Geometry
  • Comparison - compares two geometries with respect to their spatial relation
  • Generation - generates new geometries from others

PostgreSQL

PostgreSQL is a powerful, object-relational database management system (ORDBMS)

PostgreSQL is designed from the very start with extension in mind

  • the ability to add new data types, functions & access methods at run-time
  • called extension such as PostGIS

PostgreSQL Properties

  • Proven reliability and transactional integrity by default- ACID
  • Careful support for SQL standards
  • Pluggable type & function extension
  • Community-oriented development model
  • No limit on column sizes ("TOAST"able tuples )to support big GIS objects
  • Generic index structure (GiST) to allow R-Tree index
  • Easy to add custom functions

PostGIS

PostGIS turns the PostgreSQL Database Management System into a spatial database by adding support for the three features

  • spatial types
  • indexes, and
  • functions

Postgres + PostGIS Spatial Functions

Accessor functions: getters and setters

  • ST_SRID()
  • ST_Transform()
  • ST_GeometryType()
  • GeometryType()

Measurement functions : Planar measures for geometry types

  • ST_Length
  • ST_Length3D

Postgres + PostGIS Spatial Functions

Measurement functions : Planar measures for geometry types

  • ST_Area
  • ST_Perimeter

3D measurement enhancements in PostGIS 2.0

  • ST_3DClosestPoint, ST_3DDistance
  • ST_3DIntersects, ST_3DShortestLine
  • ST_3DLongestLine

Spatial Data

Spatial data have 2 important properties

  • They reference to a geographic space
  • They are represented at a variety of geographic scales

Components of Geographic objects

  • Descriptive attributes
  • Geometry (location in the underlying geographic space, shape, and so on) & topology (spatial relationships existing among objects, such as adjacency)

Spatial Data

The representation of the geometry & topology requires powerful modeling at the theme or object level which leads to spatial data models

The basic data types used in spatial data models

  • point (zero-dimensional object)
  • line (one-dimensional)
  • region (2D object)

Types of Spatial data

data-modals

Functional Classification of Spatial data

data-modals

Spatial data

2 key aspects;

  • Representation of data - The concept of geometry - a means of representing spatial data
  • Representations of data relationships - The concept of topology - a way of representing spatial relations

Concept of a Geometry

In OpenGIS Simple Feature Specification for SQL (OGC, 1999)

  • OGC proposed a hierarchy of spatial data types, called geometry object model which allows spatial features to be represented in a database
  • In the geometry object model, the word geometry is used to represent a spatial feature as an object in a database

Concept of a Geometry

As a root class of the hierarchy geometry object model

geometry is a non-instantiable construct

  • That is, it contains no occurrence or instance of real world features
  • The base geometry class has four sub-classes, namely;point, curve, surface & geometry collection

Geometric sub-classes are instantiable constructs

  • That is, they contain occurrences of instances of real world features
  • Contain a definitive set of processes, called methods, that are used to test their respective geometric properties, define their spatial relationships, & support their use in spatial analysis

Concept of a Geometry

In a spatial database, geometries that share the same attributes collectively form a layer or feature class & are stored in the same table

data-modals

Concept of Topology

The concept of topological data structures assumes that spatial features occur on a 2-dimensional plane and, therefore, relationships in spatial data can be defined by 3 primitives

  • nodes (0-cell)
  • edges (1-cell)
  • polygons (2-cells)

Topological Data Structures

  • A node (or a point) is a spatial feature of 0 dimensions where one or more edges (also called arcs, chains, and segments or lines) connect to form a topological junction
  • An edge is a spatial feature of 1 dimension that is formed by a directed, non-branching sequence of non-intersecting line segments bounded by a from and a to node
  • A polygon (or a topological ring, face or area) is a 2- dimension spatial feature that is closed on itself by a sequence of connected and directed edges

The bounding edges of a polygon reference the polygons to their left and right through the from and to nodes that define the direction of the edge

Non-topological Data Structure

Example; Shapefile data model - is a non-topological data structure because it does not explicitly store spatial relationships

  • Uses of a full-polygon data structure - which stores polygons individually as discrete entities much in the same way as a cartographic data structure

Non-topological Data Structure

Shapefile format have several constraints that stop them from being used for a number of important spatial applications

  • limited cartographic rendering capability
  • incompatibility with relational database management principles & techniques
  • absence of topology for efficient spatial (especially logistics-based networking) analysis
  • lack of support for transferring metadata that describe spatial data & their characteristics

Geo-relational Model

In this model, spatial data are abstracted into a series of independently defined layers

Spatial features represented by the same basic graphical primitive, such as lines, are classified and stored separately,again according to their feature or entity type

  • With this model, spatial features in point form are stored separately from those represented by lines, which are in turn stored separately from those represented by polygons

Store spatial and attribute data separately

Geo-relational Model

data-modals

Geodatabase Model

The advent of object-oriented & object-relational database systems

  • allows a user to define spatial data as specific abstract data types - thus making it possible to store spatial data and their associated attribute data in a single database system

By storing spatial data in an object-oriented or object-relational database

  • it is also possible to take full advantage of the available indexing, transaction management and database constraint mechanisms to maintain the integrity of the spatial data

Geodatabase Model

The new generation of spatial database systems

  • Example; geodatabase of ESRI's ArcGIS software
  • Stores various types of spatial data, topology, attribute data and metadata all using a single database system
  • Such systems can function at multiple levels of complexity from a personal geodatabase to much more complex enterprise databases

Geodatabase Model

In the new generation of systems, spatial data that share the same attributes (i.e., data of the same feature class) are stored in a single table

In this table there are 2 sets of fields;

  • Predefined fields - include the feature identifier (FID), the geometry which describes the shape of the feature, and a geometry-tracking field that records the area of the feature
  • Custom fields - are implemented by the database administrator

Geodatabase Model

data-modals

Table structure of a Geodatabase

data-modals

Topology Table

data-modals

End of Lecture 5

Spatial Database Systems

That's it!

Queries about this Lesson, please send them to: jmwaura@jkuat.ac.ke

*References*

  • Database Systems: Design, Implementation, and Project Management, Springer. Albert K W Yeung & G. Brent Hall
  • Database Systems: Design, Implementation, and Management, 12th ed. Carlos Coronel & Steven Morris
  • Database Modeling and Design; Logical Design, 5th ed. Taby Teorey et.al
  • Fundamentals of database systems, 6th ed. Ramez Elmasri & Shamkant B. Navathe
Courtesy of