Presentation is loading. Please wait.

Presentation is loading. Please wait.

Spatial Databases: Lecture 2

Similar presentations


Presentation on theme: "Spatial Databases: Lecture 2"— Presentation transcript:

1 Spatial Databases: Lecture 2
DT249, DT211,DT228 Semester 2 2016 Pat Browne

2 Topics Spatial Joins OGC Themes Indexing Spatial databases
Spatial Database Architecture PostGIS

3 Spatial Join A spatial join associates two tables based on a spatial relationship, rather than an the classic non-spatial relational attribute. A spatial join operation is used to combine two or more dataset with respect to a spatial predicate or spatial operation. Predicates can be a combination of directional, distance, and topological spatial relations (e.g. overlap, contains). In case of non-spatial join, the joining attributes must of the same type, but for spatial join they can be of different types.

4 Spatial Join Example1 Query: For all the rivers listed in the River table, find the counties through which they pass. SELECT r.name, c.name FROM river AS r, country AS c WHERE crosses(r.the_geom,c.the_geom); The spatial predicate “Cross” is used to join River and Country tables To view this we would add asbinary(R.the_geom,C.the_geom). From Title : Spatial Databases: A Tour Authors: Shashi Shekhar and Sanjay Chawla

5 Spatial Joins In practice, spatial join operations are divided into a filter step and a refinement step to efficiently process complex spatial data types such as point collections in a row instance. In the filter step, the spatial objects are represented by simpler approximations such as their Minimum Bounding Rectangle or Box (MBR or MBB). Spatial joins require spatial indexing. Spatial join operation is used to combine two or more dataset with respect to a spatial predicate. Predicate can be a combination of directional, distance, and topological spatial relations (e.g. overlap, contains,. In case of nonspatial join, the joining attributes must of the same type, but for spatial join they can be of different types.

6 Spatial Joins Example 2 A spatial join associate two tables based on a spatial relationship, rather than an attribute relationship. For example the query: Summarize the election results by city. Could be answered using the following SQL:

7 SELECT m. name, sum(v. fiannfail) AS FF, sum(v. gp) AS Green, sum(v
SELECT m.name, sum(v.fiannfail) AS FF, sum(v.gp) AS Green, sum(v.finegael) AS FG, sum(v.vtotal) AS total FROM voting_areas v, city c, WHERE intersects(v.the_geom, c.the_geom) GROUP BY c.name ORDER BY c.name; Note the && speeds up the join by using PostgreSQL’s native indexing on the geometry elements. v. So we could add the following to the where clause. the_geom && m.the_geom

8 Dynamic and Static Data
Static non-spatial data is usually maintained in the table with the geometry (e.g. county name or unique identified). In some cases this data along with the geometry is considered immutable. Dynamic non-spatial data is often maintained in a separate table e.g. land ownership. There can be more than one dynamic table for a geometry table. Dynamic spatial can include moving objects or a changing world (temporality requires different treatment)

9 Traditional Joins Pure data tables can be joined with the geometry tables for querying purposes A primary key is used to relate the 2 tables together A primary key is a unique identifier for each row in a table Primary Key

10 Spatial Join1 A typical example of spatial join is “Find all pair of rivers and cities that intersect”. The result of join between the set of rivers {R1, R2} and cities {C1, C2, C3, C4, C5} is { (R1, C1), (R2, C5)}. SPATIAL JOIN Biplob Kumar Debnath, Department of Electrical and Computer Engineering, University of Minnesota Spatial join operation is used to combine two or more dataset with respect to a spatial predicate. Predicate can be a combination of directional, distance, and topological spatial relations. In case of nonspatial join, the joining attributes must of the same type, but for spatial join they can be of different types. Usually each spatial attribute is represented by its minimum bounding rectangles (MBR).

11 Programming Languages
The basic components of current languages are: Data types e.g. Integers, String, Polygon. Variables to refer to data types e.g. a = 2 Operations on those data types e.g. area(polygon) Control structures e.g. sequence, iteration, and conditions. Logic is an important part of programming, but it is often implicit and external to the language. Some languages like SQL are quite close to logic.

12 Data types A data type represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation, legal operations and structure of values. Data types are a way to limit the kind of data that can be used by a particular program or stored in a database table. Types restrict the data to a certain set of values (e.g. 1,2,3,..for Integers). Data types also are restricted to certain operations on the type (e.g. addition for Integers). SQL comes with a range of standard data types that can be used to represent strings, integers, etc, PostgreSQL can be extended to have additional types e.g. spatial data types.

13 SQL supports data abstraction
Data Abstraction- allows users to ignore unimportant details View Level – a way of presenting data to a particular group of users Logical Level – how data is interpreted when writing queries Physical Level – how data is manipulated at storage level by a computer. Most users are not interested in the physical level.

14 Databases use high level declarative languages (SQL)
Data Definition Language (DDL) Create, alter and delete data CREATE TABLE, CREATE INDEX Data Manipulation Language (DML) Retrieve and manipulate data SELECT, UPDATE, DELETE, INSERT Data Control Languages (DCL) Control security of data GRANT, CREATE USER, DROP USER

15 Geometry Object Model GOM is “abstract” (or conceptual) part of the OGC suite of standards. It defines geometries and operations on them. The GOM is conceptual model independent of SQL or any other language, and hence is used to define more concrete implementations. The GOM is based on the Object Orientation concept of inheritance, where one class inherits attributes/methods from another. Its purpose is to harmonise academic theory and industrial practice into a workable consensus amongst practitioners. It has the following classes Abstract class: Geometry Instantiable subclasses in include: Points which represent points in 2-dimensional space Lines are linear edges between two points Linestrings are connected lines (end-point is start-point of next line) Linear Rings are ’closed’ Linestrings (last ’end-point’ is first ’start-point’) Polygons Surface within a Linear Ring, potentially excluding inner Linear Rings Uniform Collections of concrete Types

16 Spatial Types – OGC Simple Features for SQL
An association represents a family of links. Aggregation is a has-a relationship; aggregation is more specific than association. Composition is a stronger variant of the "has a" association relationship, it has a strong lifecycle dependency between instances of the container class and instances of the contained class(es). The standard does not mention UML composition, but explicitly mentions the “owned by” black dot. Multiplicity in UML allows to specify cardinality - i.e. number of elements - of some collection of elements. In the standards will ill take the open diamond to represent the part-of relation. Inheritance represents an is-a relation.

17 Spatial Types – OGC Simple Features for SQL
A black dot can be used for an association end owned by a class, an association end owned by a class is also an attribute. In some notations (ORM) the black dot is a mandatory role constraint indicating that each object must have a specific attribute. The GOM is part “abstract” (or conceptual) part of the OGC suite of standards. It defines geometries and operations on them. The GOM is conceptual model independent of SQL or any other language, and .hence is used to define more concrete implementable It has the following classes Abstract class: Geometry Instantiable subclasses in include: Points which represent points in 2-dimensional space Lines are linear edges between two points Linestrings are connected lines (end-point is start-point of next line) Linear Rings are ’closed’ Linestrings (last ’end-point’ is first ’start-point’) Polygons Surface within a Linear Ring, potentially excluding inner Linear Rings Uniform Collections of concrete Types Purpose: In common with most spatial standards its purpose is to harmonise academic theory and industrial practice into a workable consensus amongst practitioners.

18 Operations OGC Simple Feature Types

19 Operations OGC Simple Feature Types

20 OGC Simple Features for SQL1
The OGC SF (similar to ISO ) describes 2-D geometry with linear interpolation between vertices. The simple feature model consists of a root class Geometry and its subclasses Point, Curve, Surface, GeometryCollection. The class Geometry collection has the subclasses Multipoint, Multicurve, MultiSurface. ISO Standards for Geographic Information Kresse, Wolfgang, Fadaie, Kian, 2004 ISBN:

21 OGC Simple Features for SQL1
The OGC does not include complexes, a third dimension, non-linear curves, `networking or topology (i.e. connectivity information). Because of it relative simplicity and its support in both the commercial & open source community SFSQL is widely used in DBMS and is supported in many Web applications. It is expected that newer more sophisticated standards such as ISO will gradually replace OGC SF. SO Standards for Geographic Information Kresse, Wolfgang, Fadaie, Kian 2004, XII, 322 p. 137 illus., Hardcover ISBN:

22 OGC Simple Features for SQL (*)
Brief description A simple feature is defined to have both spatial and non-spatial attributes. Spatial attributes are geometry valued, and simple features are based on 2D geometry with linear interpolation between vertices. Each feature is stored as a row in a database table. This course covers the OGC: GEOMETRY type with subtypes such as POINT, LINE, POLYLINE, POLYGON, and collections of these.

23 OGC Simple Features for SQL (*)
Functionality can be described under the following headings. Basic Methods on Geometry Methods for testing Spatial Relations between geometric objects Methods that support Spatial Analysis Geometry Collection Basic Methods on Geometry Describes the dimensions and reference system (SRID) of the geometry. Operations include Dimension, GeometryType, , conversions AsText, AsBinary, tests on geometry include IsEmpty, IsSimple. Operations that return geometry Boundary, Envelope returns bounding box Methods for testing Spatial Relations between geometric objects These polymorphic methods check relations on the generic or super class GEOMETRY and usually return a Boolean. Main methods Equals, Disjoint, Intersects, Touches, Crosses, Within, Contains, Overlaps, Relate( testing for intersections between the Interior, Boundary and Exterior of the two geometries) Methods that support Spatial Analysis A set of geometric and ‘metric’ methods. Methods calculate distances and areas with respect to the spatial reference system of this Geometry. Methods include Distance, Buffer, ConvexHull, Intersection, Union, Difference, SymDifference. Geometry Collection A GeometryCollection is a geometry that is a collection of 1 or more geometries. All the elements in a GeometryCollection must be in the same Spatial Reference. Subclasses of GeometryCollection may restrict membership based on dimension and may also place other constraints on the degree of spatial overlap between elements. Methods NumGeometries( ):Integer—Returns the number of geometries in this GeometryCollection. GeometryN(N:integer):Geometry—Returns the Nth

24 OGC Simple Features for SQL (*)
Basic Methods on Geometry Describes the dimensions and reference system (SRID) of the geometry. Operations include Dimension, GeometryType, , conversions AsText, AsBinary, tests on geometry include IsEmpty, IsSimple. Operations that return geometry Boundary, Envelope returns bounding box Methods for testing Spatial Relations between geometric objects These polymorphic methods check relations on the generic or super class GEOMETRY and usually return a Boolean. Main methods Equals, Disjoint, Intersects, Touches, Crosses, Within, Contains, Overlaps, Relate( testing for intersections between the Interior, Boundary and Exterior of the two geometries) Methods that support Spatial Analysis A set of geometric and ‘metric’ methods. Methods calculate distances and areas with respect to the spatial reference system of this Geometry. Methods include Distance, Buffer, ConvexHull, Intersection, Union, Difference, SymDifference. Geometry Collection A GeometryCollection is a geometry that is a collection of 1 or more geometries. All the elements in a GeometryCollection must be in the same Spatial Reference. Subclasses of GeometryCollection may restrict membership based on dimension and may also place other constraints on the degree of spatial overlap between elements. Methods NumGeometries( ):Integer—Returns the number of geometries in this GeometryCollection. GeometryN(N:integer):Geometry—Returns the Nth

25 OGC Spatial Relations Equals – same geometries
Disjoint – geometries share common point Intersects – geometries intersect Touches – geometries intersect at common boundary Crosses – geometries overlap Within– geometry within Contains – geometry completely contains Overlaps – geometries of same dimension overlap Relate – intersection between interior, boundary or exterior

26 OGC Spatial Operations & Relations

27 Semantics of geometry Here are some of Euclid’s definitions from about 300 BC A point is that which has no part. A line is breadthless length. The ends of a line are points. A straight line is a line which lies evenly with the points on itself. A surface is that which has length and breadth only. The edges of a surface are lines. A plane surface is a surface which lies evenly with the straight lines on itself. A boundary is that which is an extremity of anything A figure is that which is contained by any boundary or boundaries. Are these definitions consistent with your understanding? Is a line really composed of points? How does a computer draw a line? The Thirteen Books of the Elements, Vol. 1: Books 1-2 Thomas L. Heath (Author), Euclid (Author) Publisher Dover A model of a modern geometry then consists of specifications of points and lines.

28 Semantics of geometry Most computer displays use raster data structures to store pixel information.

29 Drawing a line in JavaScript1
Note: Code use variable b for y-intercept. The equation of a line is y = mx + c. dx, dy are changes in x,y m is the slope. c is y-intercept. 1.

30 Drawing a line in JavaScript1
The code on the previous slide is fine when the slope is less than or equal to 1 (dx >= dy). If the slope greater than 1, the line will have gaps (dx < dy). If dx = 0 then only a single point is plotted. Most computer displays are pixel based.

31 Calculating Distance in Java
import java.util.Scanner; public class DistanceApp { public static void main(String[] args){ int x1, y1, x2, y2; double distance; Scanner scan = new Scanner (System.in); System.out.print("Enter the x coordinate for point 1: "); x1 = scan.nextInt(); System.out.println("The x coordinate for point 1: "+ x1); System.out.print("Enter the y coordinate for point 1: "); y1 = scan.nextInt(); System.out.println("The y coordinate for point 1: "+ y1); System.out.print("Enter the x coordinate for point 2: "); x2 = scan.nextInt(); System.out.println("The x coordinate for point 2: "+ y1); System.out.print("Enter the y coordinate for point 2: "); y2 = scan.nextInt(); System.out.println("The y coordinate for point 2: "+ y2); distance = Math.sqrt( Math.pow((x2 - x1),2) + Math.pow((y2 - y1),2)); System.out.println("The distance between the two points is " + distance); }} Change to floating point input using nextDouble and change coord to double. // the formula for Distance is square root of [(x2-x1)squared + (y2-y1)squared]

32 Contains Relation Does the base geometry (small circles) contain the comparison geometry (big circles)? For the base geometry to contain the comparison geometry it must be a superset of that geometry. Geographic Information Systems and Science, ,Longley,Goodchild,Maguire,Rhind

33 Some spatial relations

34 Geographic Information Systems and Science , Longley,,Goodchild,,Maguire,Rhind
Touches Relation Does the base geometry (small circles) touch the comparison geometry (big circles) ? Two geometries touch when their boundaries intersect. Raises deep mathematical issues e.g. what is the boundary of a point?, what about tolerance + or - a metre?

35 Spatial Methods Distance – shortest distance Buffer – geometric buffer
ConvexHull – smallest convex polygon geometry Intersection – points common to two geometries Union – all points in geometries Difference – points different between two geometries SymDifference – points in either, but not both of input geometries

36 Convex Hull The convex hull of a set of points is the intersection of all convex sets which contain the points. A set of points is convex if and only if for every pair of points p,q in S, the line segment pq is completely contained in S. Left is convex set and right non-convex set Convex hulls constructed around objects.

37 Operations on themes Theme projection1: ‘selecting’ some attributes from the countries theme. Get the Population and Geometry of European countries Theme selection: Name and population of European countries with a population of 50 million or more. Theme union : European countries with population less than 10 million joined with those over 10 million. Theme overlay: See example Theme merge : See example Theme projection and selection and analogous to their relational counterparts.

38 Operations on themes Theme overlay1: Generates a new theme and new geometry from the overlaid themes. We get the geometric intersection of spatial objects with the required themes. See European language example. Theme merge : The merge operation performs the geometric union of the spatial part of n geographic objects that belong to the same theme under a constraint condition supplied by the user. See East/West Germany example. overlay: Merging two geographic objects in a theme into a single object (e.g. East and West Germany) merge : The merge operation performs the geometric union of the spatial part of n geographic objects that belong to the same theme under a constraint condition supplied by the user.

39 Projection on Theme Find the countries of western Europe with population greater than 50 million. This is a projection on the attribute population. Unlike a conventional database query we often want the query result and the original context, in this case Europe.

40 Theme Merge (*) Merging two geographic objects in a selected theme (say country) into a single object.

41 Theme Overlay Anglo-Saxon Latin languages The lower map represents the overlay of European countries and languages.

42 Indexing Indexing is used to speed up queries and locate rows quickly
Traditional RDBMS use 1-d indexing (B-tree) Spatial DBMS need 2-D, hierarchical indexing Grid Quadtree R-tree Others Multi-level queries often used for performance (MBR)

43 R-tree Example of MBR for constructing an R–Tree Index of polygons

44 Minimum Bounding Rectangles
Study Area Minimum Bounding Rectangle

45 Spatial enabled DB Overivew
Database – an integrated set of data on a particular subject. Can include spatial and non-spatial and possible temporal. Databases offer many advantages over files Relational databases dominate for non-spatial use, object-relational databases (ORDBMS) often used for spatial data. Databases address some limitations for GIS

46 Guting’s1 definition of a spatial database
(1) A spatial database system is a database system (2) It offers spatial data types in its data model and query language (3) It supports spatial data types in its implementation, providing at least spatial indexing and efficient algorithms for spatial join2. 1. Ralf Hartmut Güting, Tutorial Spatial Database Systems 2. Spatial join operation is used to combine two or more dataset with respect to a spatial predicate. Predicate can be a combination of directional, distance, and topological spatial relations. In case of nonspatial join, the joining attributes must of the same type, but for spatial join they can be of different types. Usually each spatial attribute is represented by its minimum bounding rectangles (MBR).

47 Why use a database for GIS?
A GIS is strictly speaking not a database system. A GIS can be connected to a DBMS. A GIS cannot efficiently manage large quantities of non-spatial data (e.g. at government department level). They lack ad hoc querying capability (they provide a restricted form of predefined queries) They lack indexing structures for fast external data access (they use in memory techniques). They lack a 'logic' (e.g. first order logic of the relational calculus)

48 Why use a database for GIS?
Databases offer the following functions: Data independence Data Abstraction Self-describing Concurrency Distributed capabilities High performance Supports spatial data types using ADTs. Alternative: files Reliability Integrity: enforces consistency Security User views User interface Querying Updating DB theory has a Mathematical basis Data independence principle, means that the user does not need to know about data storage or lower level data representation. Users should be able to interact with a representation of data independently of actual physical storage.

49 Choice database for GIS?
Choice of DBMS: Commercial (Oracle, DB2) or Open source (PostgreSQL, MySQL) . We will PostgreSQL with PostGIS spatial extensions. PostgreSQL is an Object Relational Database System (ORDBMS).

50 Database Architecture for GIS(*)
Pure Relational Approach Spatial data can be stored in a pure RDBMS. The coordinates for the spatial data can be stored in tables. Uses existing technologies, requires no additional software (for the pure DBMS perspective). Drawbacks It is difficult to represent and query complex spatial structures (such as a polygon with holes) or topological relationships ( network connectivity, polygon adjacency). No ordered lists. Violates independence principle, user must know about data storage. Change of geometric representation requires deep reorganization of the database and query formulation. Poor performance, requires a lot of processing of the relational tuples that represent the spatial information. Lack of user friendliness because users have to manipulate tables of points. Difficulty of defining new spatial types. The impossibility of expressing geometric computations such as adjacency tests, point query, or window query.

51 Database Architecture for GIS(*)
Loosely Coupled Many commercial and government agencies use this approach. Uses a RDBMS to store 'attribute' or descriptive information e.g. the name of a road not its geometry. A specific module for spatial data management. Drawbacks The coexistence of heterogeneous data models, which implies difficulties in modeling use and integration. A partial loss of DBMS techniques e.g. recovery, querying, optimization.

52 Database Architecture for GIS(*)
Loosely Coupled Architecture Application Programs Relational DBMS Geometric Processing (GIS) Database Files

53 Database Architecture for GIS(*)
Integrated DBMS extensibility address many of the problems inherent in the RM and LC approaches. Most commercial databases that offer facilities to handle spatial data (PostgreSQL, Oracle, DB2) take this approach. The basic idea is to add new types and operations to the RM as follows: The query language is extended to manipulate spatial data as well as descriptive data. New spatial types (point, line, and polygon) are handled as basic types by the DBMS. Many other DBMS functions such as query optimization, are adapted in order to handle geo-spatial data efficiently. Drawback: Does not provide full GIS functionality (cartography). We must use additional software such as Geoserver to make (or render) an attractive map from the raw vectors stored in the DBMS.

54 What can PostGIS do? Many PostGIS functions available via SQL
Compliant with OGC1 Simple Features Specification Crosses Overlaps Contains Area Length Point on surface Return geometry as SVG Coordinate transformation Identify (SRID) Buffer Touches Crosses Within Overlaps Contains 1. The Open Geospatial Consortium, Inc.® (OGC)

55 What can PostGIS do? PostGIS supports a geometry type which is compliant with the OGC standard for Simple Features. POINT( ) LINESTRING ( 10 10, ) POLYGON ( ( 0 0, 5 5, 5 0, 0 0 ) ) MULTIPOINT ( ( 1 1 ), ( 0 0 ) ) MULTILINESTRING ( … ) MULTIPOLYGON ( … ) OPW: IMGS (Information with location) Duchas Mapflow: ESRI: Laois CC DIT-DMC ICiNG - Intelligent Cities of the Next Generation The National Centre for Geocomputation

56 HOW Spatial Databases Fit into GIS
LAN Editing Loading Analysis GIS Web Client Internet Other GIS Mapping Features Database Image from Paul Ramsey Refractions Research

57 ProstgreSQL PostgreSQL itself provides the main features of a RDBMS. Includes other advanced features such as: Inheritance Functions Constraints Triggers Rules Transactional integrity Permits an ‘OO like’ style of programming

58 PostgreSQL/PostGIS The data is stored in a relatively simple format with the attributes and geometry stored in a single table. It can be viewed as Well Known Text (WKT) or displayed graphically using the asBinary(the_geom) function. Spatial reference number Coordinates Attribute Data Data type name city hrs status st_fed the_geom Brio Refining Friendswood 50.38 active Fed SRID=32140;POINT( ) Crystal Chemical Houston 60.9 SRID=32140;POINT( ) North Cavalcade 37.08 SRID=32140;POINT( ) Dixie Oil Processors 34.21 SRID=32140;POINT( ) Federated Metals 21.28 State SRID=32140;POINT( )

59 How does it work? Spatial data is stored using the coordinate system of a particular projection. That projection is referenced with a Spatial Reference Identification Number (SRID) This number relates to another table (spatial_ref_sys) which holds all of the spatial reference systems available. This allows the database to know what projection each table is in, and if need be, re-project from those tables for calculations or joining with other tables.

60 Coordinate Projection
SRID=3005;MULTILINESTRING(( , )) NORTH AMERICAN DATUM OF 1983 SRID 3005=NAD83 SRID 4326=WGS84 SRID=4326;MULTILINESTRING(( , )) Coordinates of one table can be converted to those of another table. This permits the ‘geometry’ in each table to match. Relatively easy to do in PostGIS

61 Spatial Database Components
The Geometry metadata table table schema table name geometry column coord dim srid type brazos texas_counties the_geom 2 32139 MULTIPOLYGON texas_rivers MULTILINESTRING texas_roads tx_maj_aquifers tx_min_aquifers txzip_codes bz_landmarks POINT

62 spatial_ref_sys postgis=# \d spatial_ref_sys
Table "public.spatial_ref_sys" Column | Type | Modifiers srid | integer | not null auth_name | character varying(256) | auth_srid | integer | srtext | character varying(2048) | proj4text | character varying(2048) | Indexes: "spatial_ref_sys_pkey" PRIMARY KEY, btree (srid)

63 geometry_columns postgis=# \d geometry_columns
Table "public.geometry_columns" Column | Type | Modifiers f_table_catalog | character varying(256) | not null f_table_schema | character varying(256) | not null f_table_name | character varying(256) | not null f_geometry_column | character varying(256) | not null coord_dimension | integer | not null srid | integer | not null type | character varying(30) | not null Indexes: "geometry_columns_pk" PRIMARY KEY, btree (f_table_catalog, f_table_schema, f _table_name, f_geometry_column)

64 Database Rules Rules help prevent human error when modifying a data set Rules are user defined Rules are such things as; “A fire hydrant must be located on a water line” Rivers should flow down hill.

65 Constraints Constraints are similar to rules, but are less assertive.
Constraints are provided by the DBMS and are applied by the user A Constraint would be “Parcel_ID Not Null” - meaning a number ID has to be provided when a parcel is created.

66 Constraints Constraint GIS examples Uniqueness
Two spatial objects cannot exist at the same point Non-Null All Address points must have co-ordinates Range All heights in Ireland must be in range -100 to 2000 metres Relationship Every river must be connected to the sea, a lake or other river (Can rivers cross) Cardinality Each side of a triangle has a 1:2 relation with the others Inclusion All counties are polygons Covering A boundary may be a townland and/or a barony. Disjointedness All roads must be only a primary or a secondary or a regional Referential Integrity A county border must be represented by a ground feature Geometrical Triangles must have three sides Orientation Roads are usually to the front of houses Topological Inner walls must be "inside" buildings General Complex rules built from above constraints

67 Constraints How can we define in front of?

68 Data integrity Valid Invalid
select count(*) from voting_areas where not isvalid(the_geom);

69 Temporal Example: roads, buildings, and regions
Consider a line. From the properties of metric spaces it has a length.

70 Temporal Example: roads, buildings, and regions
Lets call it a road. From graph theory we have a path

71 Temporal Example: roads, buildings, and regions
F1 B Purple line segment represents both a road and a fence. Lets add a field (F1) with an area and a topology.

72 Example: roads, buildings, and regions
F1 B Lets add an administrative region (outer red rectangle) and some houses

73 Example: roads, buildings, and regions
F2 F3 B Lets divide the field in two by inserting a new fence. We need to delete the old area and add two new areas. What about adjacency relation between fields?

74 Example: roads, buildings, and regions
Time1 Time2 A A F1 F2 F3 B B Imagine a picture of the world at Time1 and Time2. Not only have some objects changed but some spatial relationships have changed. An addition can induce a deletion and a deletion can induce an insertion.

75 Example of temporal queries
Is there a route from A to B? (now is assumed) Was there a route from A to B in Time1? Does the route in query 1 pass through the administrative region? Does the route in query 1 pass touch the administrative region ? What fields were adjacent to F2 in Time2?

76 Raster Image Data Not Covered
In this course Raster data only serves as a background.


Download ppt "Spatial Databases: Lecture 2"

Similar presentations


Ads by Google