spatial database souhad daraghma. definition a spatial database is a database that is optimized to...

30
Spatial Database Spatial Database Souhad Daraghma Souhad Daraghma

Upload: anna-singleton

Post on 16-Jan-2016

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial DatabaseSpatial Database

Souhad DaraghmaSouhad Daraghma

Page 2: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

DefinitionDefinition

A spatial database is a database that is A spatial database is a database that is optimized to store and query data related to optimized to store and query data related to objects in space, including points, lines and objects in space, including points, lines and polygons. polygons.

While typical databases can understand While typical databases can understand various numeric and character types of data, various numeric and character types of data, additional functionality needs to be added for additional functionality needs to be added for databases to process spatial data types. databases to process spatial data types. These are typically called geometry or feature.These are typically called geometry or feature.

Page 3: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Databases BackgroundSpatial Databases Background

Spatial databases provide structures for Spatial databases provide structures for storage and analysis of spatial datastorage and analysis of spatial data

Spatial data is comprised of objects in Spatial data is comprised of objects in multi-dimensional spacemulti-dimensional space

Storing spatial data in a standard Storing spatial data in a standard database would require excessive database would require excessive amounts of spaceamounts of space

Page 4: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Databases Background Spatial Databases Background (Cont.)(Cont.)

Queries to retrieve and analyze spatial Queries to retrieve and analyze spatial data from a standard database would be data from a standard database would be long and cumbersome leaving a lot of long and cumbersome leaving a lot of room for errorroom for error

Spatial databases provide much more Spatial databases provide much more efficient storage, retrieval, and analysis of efficient storage, retrieval, and analysis of spatial dataspatial data

Page 5: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Types of Data Stored in Spatial Types of Data Stored in Spatial DatabasesDatabases

Two-dimensional data examplesTwo-dimensional data examples GeographicalGeographical Cartesian coordinates (2-D)Cartesian coordinates (2-D) NetworksNetworks DirectionDirection

Page 6: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Types of Data Stored in Spatial Types of Data Stored in Spatial Databases Databases (Cont.)(Cont.)

Three-dimensional data examplesThree-dimensional data examples WeatherWeather Cartesian coordinates (3-D)Cartesian coordinates (3-D) TopologicalTopological Satellite imagesSatellite images

Page 7: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Databases Uses and UsersSpatial Databases Uses and Users

Three types of usesThree types of uses Manage spatial dataManage spatial data Analyze spatial dataAnalyze spatial data High level utilizationHigh level utilization

Page 8: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Databases Uses and Users Spatial Databases Uses and Users (Cont.)(Cont.)

A few examples of usersA few examples of users Transportation agency tracking projectsTransportation agency tracking projects Insurance risk manager considering location Insurance risk manager considering location

risk profilesrisk profiles Doctor comparing Magnetic Resonance Doctor comparing Magnetic Resonance

Images (MRIs)Images (MRIs) Emergency response determining quickest Emergency response determining quickest

route to victimroute to victim Mobile phone companies tracking phone Mobile phone companies tracking phone

usageusage

Page 9: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Database Management Spatial Database Management SystemSystem

Spatial Database Management System Spatial Database Management System (SDBMS) provides the capabilities of a (SDBMS) provides the capabilities of a traditional database management system traditional database management system (DBMS) while allowing special storage and (DBMS) while allowing special storage and handling of spatial data.handling of spatial data.

Page 10: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Database Management Spatial Database Management System System (Cont.)(Cont.)

SDBMS:SDBMS: Works with an underlying DBMSWorks with an underlying DBMS Allows spatial data models and typesAllows spatial data models and types Supports querying language specific to spatial Supports querying language specific to spatial

data typesdata types Provides handling of spatial data and Provides handling of spatial data and

operationsoperations

Page 11: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

SDBMS Three-layer StructureSDBMS Three-layer Structure

SDBMS works with a spatial application at SDBMS works with a spatial application at the front end and a DBMS at the back endthe front end and a DBMS at the back end

SDBMS has three layers:SDBMS has three layers: Interface to spatial applicationInterface to spatial application Core spatial functionalityCore spatial functionality Interface to DBMSInterface to DBMS

Page 12: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

SDBMS Three-layer Structure SDBMS Three-layer Structure (Cont.)(Cont.)

Sp

atia

l ap

plic

atio

n

DB

MS

Inte

rfac

e to

DB

MS

Inte

rfac

e to

sp

atia

l ap

plic

atio

n

Core Spatial Functionality

Taxonomy

Data types

Operations

Query language

Algorithms

Access methods

Page 13: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Query LanguageSpatial Query Language

Number of specialized adaptations of SQLNumber of specialized adaptations of SQL Spatial query language Spatial query language Temporal query language (TSQL2)Temporal query language (TSQL2) Object query language (OQL)Object query language (OQL) Object oriented structured query Object oriented structured query

language (Olanguage (O22SQL)SQL)

Page 14: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Query Language Spatial Query Language (Cont.)(Cont.)

Spatial query language provides tools and Spatial query language provides tools and structures specifically for working with structures specifically for working with spatial dataspatial data

SQL3 provides 2D geospatial types and SQL3 provides 2D geospatial types and functionsfunctions

Page 15: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Query Language Spatial Query Language OperationsOperations

Three types of queries:Three types of queries: Basic operations on all data types (e.g. Basic operations on all data types (e.g.

IsEmpty, Envelope, Boundary)IsEmpty, Envelope, Boundary) Topological/set operators (e.g. Disjoint, Topological/set operators (e.g. Disjoint,

Touch, Contains)Touch, Contains) Spatial analysis (e.g. Distance, Spatial analysis (e.g. Distance,

Intersection, SymmDiff)Intersection, SymmDiff)

Page 16: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Data Entity CreationSpatial Data Entity Creation

Form an entity to hold county names, Form an entity to hold county names, states, populations, and geographiesstates, populations, and geographies

CREATE TABLE County(CREATE TABLE County(

Name Name varchar(30),varchar(30),

State State varchar(30),varchar(30),

PopPop Integer,Integer,

ShapeShape Polygon);Polygon);

Page 17: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Data Entity Creation (Cont.)Spatial Data Entity Creation (Cont.)

Form an entity to hold river names, Form an entity to hold river names, sources, lengths, and geographiessources, lengths, and geographies

CREATE TABLE River(CREATE TABLE River(

Name Name varchar(30),varchar(30),

SourceSource varchar(30),varchar(30),

DistanceDistance Integer,Integer,

ShapeShape LineString);LineString);

Page 18: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Example Spatial QueryExample Spatial Query

Find all the counties that border on Contra Find all the counties that border on Contra Costa countyCosta county

SELECT SELECT C1.Name C1.Name

FROMFROM County C1, County C2County C1, County C2

WHEREWHERE Touch(C1.Shape, C2.Shape) Touch(C1.Shape, C2.Shape) = 1 AND C2.Name = ‘Contra Costa’;= 1 AND C2.Name = ‘Contra Costa’;

Page 19: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Example Spatial Query Example Spatial Query (Cont.)(Cont.)

Find all the counties through which the Find all the counties through which the Merced river runsMerced river runs

SELECT SELECT C.Name, R.NameC.Name, R.Name

FROMFROM County C, River RCounty C, River R

WHEREWHERE Intersect(C.Shape, R.Shape) Intersect(C.Shape, R.Shape) = 1 AND R.Name = ‘Merced’;= 1 AND R.Name = ‘Merced’;

Page 20: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Features of Spatial DatabasesFeatures of Spatial Databases

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

In addition to typical SQL queries such as In addition to typical SQL queries such as SELECT statements, spatial databases can SELECT statements, spatial databases can perform a wide variety of spatial operations. perform a wide variety of spatial operations.

Page 21: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Features of Spatial Databases Features of Spatial Databases (Cont.) - (Cont.) - query typesquery types

The following query types and many The following query types and many more are supported by the Open more are supported by the Open Geospatial Consortium:Geospatial Consortium:

Spatial Measurements:Spatial Measurements: Finds the Finds the distance between points, polygon area, distance between points, polygon area, etc. etc.

Page 22: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Features of Spatial Databases Features of Spatial Databases (Cont.) - (Cont.) - query typesquery types

Spatial Functions:Spatial Functions: Modify existing Modify existing features to create new ones, for example features to create new ones, for example by providing a buffer around them, by providing a buffer around them, intersecting features, etc.intersecting features, etc.

Spatial Predicates:Spatial Predicates: Allows true/false Allows true/false queries such as 'is there a residence queries such as 'is there a residence located within a mile of the area we are located within a mile of the area we are planning to build the landfill?' planning to build the landfill?'

Page 23: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Features of Spatial Databases Features of Spatial Databases (Cont.) - (Cont.) - query typesquery types

Constructor Functions:Constructor Functions: Creates new Creates new features with an SQL query specifying the features with an SQL query specifying the vertices (points of nodes) which can make vertices (points of nodes) which can make up lines. If the first and last vertex of a line up lines. If the first and last vertex of a line are identical the feature can also be of the are identical the feature can also be of the type polygon (a closed line). type polygon (a closed line).

Observer Functions:Observer Functions: Queries which Queries which return specific information about a feature return specific information about a feature such as the location of the center of a such as the location of the center of a circle circle

Page 24: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Types of queries - PostGISTypes of queries - PostGIS

The function names for queries differ across The function names for queries differ across geodatabases. The following list contains geodatabases. The following list contains commonly used functions built into commonly used functions built into PostGIS, a free geodatabase which is a PostGIS, a free geodatabase which is a PostgreSQL extension (the term PostgreSQL extension (the term 'geometry' refers to a point, line, box or 'geometry' refers to a point, line, box or other two or three dimensional shape): other two or three dimensional shape):

Page 25: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Types of queries - PostGIS Types of queries - PostGIS (Cont.)(Cont.)

1.1. Distance(geometry, geometry) : number Distance(geometry, geometry) : number

2.2. Equals(geometry, geometry) : boolean Equals(geometry, geometry) : boolean

3.3. Disjoint(geometry, geometry) : boolean Disjoint(geometry, geometry) : boolean

4.4. Intersects(geometry, geometry) : boolean Intersects(geometry, geometry) : boolean

5.5. Touches(geometry, geometry) : boolean Touches(geometry, geometry) : boolean

6.6. Crosses(geometry, geometry) : boolean Crosses(geometry, geometry) : boolean

Page 26: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Types of queries - PostGIS Types of queries - PostGIS (Cont.)(Cont.)

7.7. Overlaps(geometry, geometry) : boolean Overlaps(geometry, geometry) : boolean

8.8. Contains(geometry, geometry) : boolean Contains(geometry, geometry) : boolean

9.9. Intersects(geometry, geometry) : boolean Intersects(geometry, geometry) : boolean

10.10. Length(geometry) : number Length(geometry) : number

11.11. Area(geometry) : number Area(geometry) : number

12.12. Centroid(geometry) : geometry Centroid(geometry) : geometry

Page 27: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial RelationsSpatial Relations Topological RelationsTopological Relations: containment, overlapping, : containment, overlapping,

etc. [Egenhofer et al. 1991]etc. [Egenhofer et al. 1991]

Metric RelationsMetric Relations: distance between objects, etc. : distance between objects, etc. [Gold and Roos 1994][Gold and Roos 1994]

Direction RelationsDirection Relations: north of, south of, etc. : north of, south of, etc. [Hernandez et al. 1990; Frank et al. 1991][Hernandez et al. 1990; Frank et al. 1991]

A BBA

B

A

1 KmA B

Page 28: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

TopologicalTopological Relations Relations

Topological relations are defined Topological relations are defined using using point-set topologypoint-set topology concepts, concepts, such as such as boundaryboundary and and interior.interior.

Page 29: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

TopologicalTopological Relations (Cont.) Relations (Cont.) For example: For example:

the the boundaryboundary of a region consists of a set of a region consists of a set of curves that separate the region from the of curves that separate the region from the rest of the coordinate spacerest of the coordinate space

The The interiorinterior of a region consists of all points of a region consists of all points in the region that are not on its boundaryin the region that are not on its boundary

Given this, two regions are said to be Given this, two regions are said to be adjacentadjacent if they share part of a boundary if they share part of a boundary but do not share any points in their interiorbut do not share any points in their interior

Page 30: Spatial Database Souhad Daraghma. Definition  A spatial database is a database that is optimized to store and query data related to objects in space,

Spatial Relations ModelSpatial Relations Model

An abstract modelAn abstract model (or conceptual model): is (or conceptual model): is a theoretical construct that represents a theoretical construct that represents something, with a set of variables and a set something, with a set of variables and a set of logical and quantitative relationships of logical and quantitative relationships between them.between them.

Models in this sense are constructed to Models in this sense are constructed to enable reasoning within an idealized logical enable reasoning within an idealized logical framework about these processes and are an framework about these processes and are an important component of scientific theories. important component of scientific theories.