Spatial Database

spatial database is a database that is optimized to store and query data that is related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types. These are typically called geometry or feature. The Open Geospatial Consortium created the Simple Features specification and sets standards for adding spatial functionality to database systems.

Database systems use indexes to quickly look up values and the way that most databases index data is not optimal for spatial queries. Instead, spatial databases use a spatial index to speed up database operations.

In addition to typical SQL queries such as SELECT statements, spatial databases can perform a wide variety of spatial operations. The following query types and many more are supported by the Open Geospatial Consortium:

  • Spatial Measurements: Finds the distance between points, polygon area, etc.
  • Spatial Functions: Modify existing features to create new ones, for example by providing a buffer around them, intersecting features, etc.
  • Spatial Predicates: Allows true/false queries such as 'is there a residence located within a mile of the area we are planning to build the landfill?' (see DE-9IM)
  • Constructor Functions: Creates new features with an SQL query specifying the vertices (points of nodes) which can make up lines. If the first and last vertex of a line are identical the feature can also be of the type polygon (a closed line).
  • Observer Functions: Queries which return specific information about a feature such as the location of the center of a circle

Not all spatial databases support these query types: many support simplified or modified sets, especially in cases of NoSQL systems like MongoDB and CouchDB.