Spatial Databases
Submitted to :
Dr A. Sai Sabitha
Submitted by:
Pratibha chaudhary
Spatial Databases
 Spatial data is comprised of objects in multi-dimensional
space
 Storing spatial data in a standard database would
require excessive amounts of space
 Queries to retrieve and analyze spatial data from a
standard database would be long and cumbersome
leaving a lot of room for error.
 Spatial databases provide much more efficient storage,
retrieval, and analysis of spatial data.
 Geodatabase
A geodatabase (also geographical
database and geospatial database) is
a database of geographic data, such
as countries, administrative divisions, cities, and related
information. Such databases can be useful for websites
that wish to identify the locations of their visitors for
customization purposes.
Spatial databases
 Used for storing and querying data that
represents objects defined in a geometric space.
 simple geometric objects such as points, lines
and polygons.
 complex geometric objects such as 3D objects,
topological coverage, linear networks, and TINs.
 While typical databases require additional
functionality to process spatial data types
efficiently, and developers have often
added geometry or feature data types.
 The Open Geospatial Consortium developed
the Simple Features specification (first released in
1997) and sets standards for adding spatial
functionality to database systems.
Types of Data Stored in Spatial
Databases
 Two-dimensional data examples
 Geographical
 Cartesian coordinates (2-D)
 Networks
 Direction
 Three-dimensional data examples
 Weather
 Cartesian coordinates (3-D)
 Topological
 Satellite images
Spatial Data Objects
 The figure below depicts the geometry hierarchy
upon which the geometry and geography data
types are based. The instantiable types
of geometry and geography are indicated in
blue.
 Simple types and collection types.
Spatial Data objects
 Simpe types:
 Point is a 0-dimensional object representing a single location and
may contain Z (elevation) and M (measure) values.
 A LineString is a one-dimensional object representing a
sequence of points and the line segments connecting them.
 A CircularString is a collection of zero or more continuous
circular arc segments. A circular arc segment is a curved
segment defined by three points in a two-dimensional plane; the
first point cannot be the same as the third point. If all three points
of a circular arc segment are collinear, the arc segment is treated
as a line segment.
 A Polygon is a two-dimensional surface stored as a sequence of
points defining an exterior bounding ring and zero or more interior
rings.
 A CompoundCurve is a collection of zero or more
continuous CircularString or LineString instances of either
geometry or geography types.
 Collection types: are collection of single type of data or the
multiple type of data.
Spatial Databases Uses and
Users
 Three types of uses
 Manage spatial data
 Analyze spatial data
 High level utilization
 A few examples of users
 Transportation agency tracking projects
 Insurance risk manager considering location risk
profiles
 Doctor comparing Magnetic Resonance Images
(MRIs)
 Emergency response determining quickest route to
victim
 Mobile phone companies tracking phone usage
Spatial Database Management
System
 Spatial Database Management System (SDBMS)
provides the capabilities of a traditional database
management system (DBMS) while allowing
special storage and handling of spatial data.
 SDBMS:
 Works with an underlying DBMS
 Allows spatial data models and types
 Supports querying language specific to spatial data
types
 Provides handling of spatial data and operations
SDBMS Three-layer Structure
 SDBMS works with a spatial application at
the front end and a DBMS at the back end
 SDBMS has three layers:
 Interface to spatial application
 Core spatial functionality
 Interface to DBMS
Spatialapplication
DBMS
InterfacetoDBMS
Interfacetospatialapplication
Core Spatial
Functionality
Taxonomy
Data types
Operations
Query
language
Algorithms
Access
methods
Features of spatial databases
 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 spatial operations.
 The following operations and many more are specified by
the Open Geospatial Consortium standard:
 Spatial Measurements: Computes line length, polygon area, the
distance between geometries, 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 about spatial
relationships between geometries. Examples include "do two
polygons overlap" or 'is there a residence located within a mile of
the area we are planning to build the landfill?'
 Geometry Constructors: Creates new geometries, usually by
specifying the vertices (points or nodes) which define the shape.
 Observer Functions: Queries which return specific information
about a feature such as the location of the center of a circle
Spatial index
 Spatial indices are used by spatial databases to
optimize spatial queries.
 Conventional index types do not efficiently handle spatial queries
such as how far two points differ, or whether points fall within a
spatial area of interest. Common spatial index methods include:
 HHCode
 Grid (spatial index)
 Z-order (curve)
 Quadtree
 Octree
 UB-tree
 M-tree
 R-tree: Typically the preferred method for indexing spatial
data .Objects (shapes, lines and points) are grouped using
the minimum bounding rectangle (MBR). Objects are added to an
MBR within the index that will lead to the smallest increase in its
size.
Spatial Query Language
 Number of specialized adaptations of SQL
 Spatial query language
 Temporal query language (TSQL2)
 Object query language (OQL)
 Object oriented structured query language (O2SQL)
 Spatial query language provides tools and
structures specifically for working with spatial data
 SQL3 provides 2D geospatial types and functions
Spatial Query Language
Operations
 Three types of queries:
 Basic operations on all data types (e.g. IsEmpty,
Envelope, Boundary)
 Topological/set operators (e.g. Disjoint, Touch,
Contains)
 Spatial analysis (e.g. Distance, Intersection,
SymmDiff)
Spatial Data Entity Creation
 Form an entity to hold country names, states,
populations, and geographies
CREATE TABLE Country(
Name varchar(30),
State varchar(30),
Pop Integer,
Shape Polygon);
 Form an entity to hold river names, sources, lengths,
and geographies
CREATE TABLE River(
Name varchar(30),
Source varchar(30),
Distance Integer,
Shape LineString);
Implementation
 Software used:
 phpMyAdmin
MYSql
 MySQL spatial extensions enable the generation,
storage, and analysis of geographic features.
 A geographic feature(geometry) is anything in
the world that has a location.
A feature can be:
An entity. For example, a mountain, a pond, a city.
A space. For example, town district, the tropics.
A definable location. For example, a crossroad, as a
particular place where two streets intersect.
Supported Spatial Data Formats
 Two standard spatial data formats are used to
represent geometry objects in queries:
 Well-Known Text (WKT) format
 Well-Known Binary (WKB) format
 (Internal format is like WKB but with an initial 4
bytes to indicate the SRID.
Well-Known Text (WKT) Format
 representation of geometry values is designed for
exchanging geometry data in ASCII form.
 The OpenGIS specification provides a Backus-
Naur grammar that specifies the formal
production rules for writing WKT values.
Queries
To create a table named geom that has a column
named g that can store values of any geometry
type, use this statement:
-Create table geom(g geometry);
Queries….
 Describe table.
INSERT INTO geom VALUES (ST_GeomFr
omText('POINT(1 1)'))
Two ways of inserting values:
 INSERT INTO geom VALUES
(ST_GeomFromText('POINT(1 1)'));
 SET @g = 'POINT(1 1)';
 INSERT INTO geom VALUES
(ST_GeomFromText(@g));
References
 http://ieor.berkeley.edu/~goldberg/courses/F04/21
5/215-SpatialDB.ppt
 https://en.wikipedia.org/wiki/Spatial_database
 https://technet.microsoft.com/en-
us/library/bb964711(v=sql.110).aspx

Spatial Databases

  • 1.
    Spatial Databases Submitted to: Dr A. Sai Sabitha Submitted by: Pratibha chaudhary
  • 2.
    Spatial Databases  Spatialdata is comprised of objects in multi-dimensional space  Storing spatial data in a standard database would require excessive amounts of space  Queries to retrieve and analyze spatial data from a standard database would be long and cumbersome leaving a lot of room for error.  Spatial databases provide much more efficient storage, retrieval, and analysis of spatial data.  Geodatabase A geodatabase (also geographical database and geospatial database) is a database of geographic data, such as countries, administrative divisions, cities, and related information. Such databases can be useful for websites that wish to identify the locations of their visitors for customization purposes.
  • 3.
    Spatial databases  Usedfor storing and querying data that represents objects defined in a geometric space.  simple geometric objects such as points, lines and polygons.  complex geometric objects such as 3D objects, topological coverage, linear networks, and TINs.  While typical databases require additional functionality to process spatial data types efficiently, and developers have often added geometry or feature data types.  The Open Geospatial Consortium developed the Simple Features specification (first released in 1997) and sets standards for adding spatial functionality to database systems.
  • 4.
    Types of DataStored in Spatial Databases  Two-dimensional data examples  Geographical  Cartesian coordinates (2-D)  Networks  Direction  Three-dimensional data examples  Weather  Cartesian coordinates (3-D)  Topological  Satellite images
  • 5.
    Spatial Data Objects The figure below depicts the geometry hierarchy upon which the geometry and geography data types are based. The instantiable types of geometry and geography are indicated in blue.  Simple types and collection types.
  • 6.
    Spatial Data objects Simpe types:  Point is a 0-dimensional object representing a single location and may contain Z (elevation) and M (measure) values.  A LineString is a one-dimensional object representing a sequence of points and the line segments connecting them.  A CircularString is a collection of zero or more continuous circular arc segments. A circular arc segment is a curved segment defined by three points in a two-dimensional plane; the first point cannot be the same as the third point. If all three points of a circular arc segment are collinear, the arc segment is treated as a line segment.  A Polygon is a two-dimensional surface stored as a sequence of points defining an exterior bounding ring and zero or more interior rings.  A CompoundCurve is a collection of zero or more continuous CircularString or LineString instances of either geometry or geography types.  Collection types: are collection of single type of data or the multiple type of data.
  • 7.
    Spatial Databases Usesand Users  Three types of uses  Manage spatial data  Analyze spatial data  High level utilization  A few examples of users  Transportation agency tracking projects  Insurance risk manager considering location risk profiles  Doctor comparing Magnetic Resonance Images (MRIs)  Emergency response determining quickest route to victim  Mobile phone companies tracking phone usage
  • 8.
    Spatial Database Management System Spatial Database Management System (SDBMS) provides the capabilities of a traditional database management system (DBMS) while allowing special storage and handling of spatial data.  SDBMS:  Works with an underlying DBMS  Allows spatial data models and types  Supports querying language specific to spatial data types  Provides handling of spatial data and operations
  • 9.
    SDBMS Three-layer Structure SDBMS works with a spatial application at the front end and a DBMS at the back end  SDBMS has three layers:  Interface to spatial application  Core spatial functionality  Interface to DBMS Spatialapplication DBMS InterfacetoDBMS Interfacetospatialapplication Core Spatial Functionality Taxonomy Data types Operations Query language Algorithms Access methods
  • 10.
    Features of spatialdatabases  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 spatial operations.  The following operations and many more are specified by the Open Geospatial Consortium standard:  Spatial Measurements: Computes line length, polygon area, the distance between geometries, 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 about spatial relationships between geometries. Examples include "do two polygons overlap" or 'is there a residence located within a mile of the area we are planning to build the landfill?'  Geometry Constructors: Creates new geometries, usually by specifying the vertices (points or nodes) which define the shape.  Observer Functions: Queries which return specific information about a feature such as the location of the center of a circle
  • 11.
    Spatial index  Spatialindices are used by spatial databases to optimize spatial queries.  Conventional index types do not efficiently handle spatial queries such as how far two points differ, or whether points fall within a spatial area of interest. Common spatial index methods include:  HHCode  Grid (spatial index)  Z-order (curve)  Quadtree  Octree  UB-tree  M-tree  R-tree: Typically the preferred method for indexing spatial data .Objects (shapes, lines and points) are grouped using the minimum bounding rectangle (MBR). Objects are added to an MBR within the index that will lead to the smallest increase in its size.
  • 12.
    Spatial Query Language Number of specialized adaptations of SQL  Spatial query language  Temporal query language (TSQL2)  Object query language (OQL)  Object oriented structured query language (O2SQL)  Spatial query language provides tools and structures specifically for working with spatial data  SQL3 provides 2D geospatial types and functions
  • 13.
    Spatial Query Language Operations Three types of queries:  Basic operations on all data types (e.g. IsEmpty, Envelope, Boundary)  Topological/set operators (e.g. Disjoint, Touch, Contains)  Spatial analysis (e.g. Distance, Intersection, SymmDiff)
  • 14.
    Spatial Data EntityCreation  Form an entity to hold country names, states, populations, and geographies CREATE TABLE Country( Name varchar(30), State varchar(30), Pop Integer, Shape Polygon);  Form an entity to hold river names, sources, lengths, and geographies CREATE TABLE River( Name varchar(30), Source varchar(30), Distance Integer, Shape LineString);
  • 15.
  • 16.
    MYSql  MySQL spatialextensions enable the generation, storage, and analysis of geographic features.  A geographic feature(geometry) is anything in the world that has a location. A feature can be: An entity. For example, a mountain, a pond, a city. A space. For example, town district, the tropics. A definable location. For example, a crossroad, as a particular place where two streets intersect.
  • 17.
    Supported Spatial DataFormats  Two standard spatial data formats are used to represent geometry objects in queries:  Well-Known Text (WKT) format  Well-Known Binary (WKB) format  (Internal format is like WKB but with an initial 4 bytes to indicate the SRID.
  • 18.
    Well-Known Text (WKT)Format  representation of geometry values is designed for exchanging geometry data in ASCII form.  The OpenGIS specification provides a Backus- Naur grammar that specifies the formal production rules for writing WKT values.
  • 19.
    Queries To create atable named geom that has a column named g that can store values of any geometry type, use this statement: -Create table geom(g geometry);
  • 20.
  • 22.
    INSERT INTO geomVALUES (ST_GeomFr omText('POINT(1 1)'))
  • 24.
    Two ways ofinserting values:  INSERT INTO geom VALUES (ST_GeomFromText('POINT(1 1)'));  SET @g = 'POINT(1 1)';  INSERT INTO geom VALUES (ST_GeomFromText(@g));
  • 27.