Presentation is loading. Please wait.

Presentation is loading. Please wait.

Spatial Databases Reading: None. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn the need for spatial databases some.

Similar presentations


Presentation on theme: "Spatial Databases Reading: None. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn the need for spatial databases some."— Presentation transcript:

1 Spatial Databases Reading: None

2 Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn the need for spatial databases some of the special issues regarding spatial data some of the issues concerning spatial database query languages some of the techniques used in spatial databases

3 Dept. of Computing Science, University of Aberdeen3 Applications of Spatial Databases Spatial databases are used to store & manipulate data concerning: –Geography (2D) - maps, socio-economic, military –Engineering (2D/3D) - architectural drawings, CAD –Geophysics (3D) - geological strata, oil fields, mining Here, we will focus on Geographic Information Systems (GIS). These usually: –combine 2D spatial & textual data –have a graphical front-end –have an extended query language

4 Dept. of Computing Science, University of Aberdeen4 Special Issues With Spatial Databases Spatial objects: –have geometric shape, size, location (i.e. coordinate) –might change with time - e.g. land-use, urban areas Issues: –Representation - how to represent e.g. a lake or a hill? –Query Languages - how to specify spatial queries? e.g. find all lakes near mountains (a spatial join) –Indexing - how to accelerate spatial access methods –Data Collection - digitise satellite images, paper maps

5 Dept. of Computing Science, University of Aberdeen5 Conceptual Modelling for Spatial Databases Conceptual modelling for spatial databases is similar to E-R modelling: But there are some important differences: CountryLake Has 1..1 0..* RelationalSpatial Simple data typesGeometric objects - lines, polygons EntitiesThemes - lakes, rivers, countries, cities Results TablesMaps - e.g. map of Scottish lakes (!)

6 Dept. of Computing Science, University of Aberdeen6 Logical Modelling - Using Relational Model namecapitalpopulationboundaryId GermanyBerlin80B1 FranceParis60B2 ………… boundaryIdcontourId B1C1 B2C2 B2C3 …… contourIdpoint_numpointId C12P1 C11P2 C13P3 ……… pointIdxy P14521000 P2365875 P3386985 ……… CountryBoundary Point Contour

7 Dept. of Computing Science, University of Aberdeen7 Query - Example Return the contours of France An SQL Query: Select Boundary.id-controur,x,y From Country,Boundary,Contour,Point Where name = France And Country.id-boundary=Boundary.id-boundary And Boundary.id-contour=Contour.id-contour And Contour.id-point=Point.id-point Order by Boundary.id-contour,point-num; Several problems as seen next

8 Dept. of Computing Science, University of Aberdeen8 Problems with using RDBMS for Spatial Data Formulating queries requires knowledge of the spatial objects structure –New queries with change in structure Bad performance –More space used and more cost in computing joins User unfriendly –Manipulating points is not easy Difficulty n defining new spatial types Impossible to express geometric computations –Adjacency test, point query or window query

9 Dept. of Computing Science, University of Aberdeen9 Abstract Data Types for Spatial Data Clearly, we need some Abstract Data Types (ADTs) and associated method functions for spatial data, e.g.: –Point - Coordinates –Line - Coordinates, Length –Polygon - Coordinates, Perimeter, Area Higher-order ADTs can be built from these basic types, e.g.: –Arc - a connected line list (start/end pts special) –Region - a set of non-overlapping polygons

10 Dept. of Computing Science, University of Aberdeen10 Geometric Method Functions Most GISs provide high-level method functions for geometric objects, e.g.: –Boolean Inside(Point, Polygon) –Boolean Crosses(Line, Polygon) –Boolean Overlaps(Region, Region) –Region Union(Region, Region) –Region Intersect(Region, Region) –Region Clip(Region, Polygon) We will not be concerned with how these are implemented!

11 Dept. of Computing Science, University of Aberdeen11 Types of Spatial Query What kinds of spatial query should spatial databases support ? Here are a few: Point - select all objects whose geometry contains a given point Window - select all objects within a given rectangle Join - select all pairs of objects that satisfy a given relationship - overlap, containment, adjacency...

12 Dept. of Computing Science, University of Aberdeen12 Desirable Features for GIS Query Languages What features should a spatial database query language have ? –Extensible - build complex objects from simpler ADTs –Programmable - supports user-defined functions –Reusable Methods - Weak typing (ADO) or object inheritance (Java) –Easy to learn - ? –Looks like SQL - ?? Which of the above do SQL satisfy ?

13 Dept. of Computing Science, University of Aberdeen13 Existing Spatial Query Languages Different groups have attempted to extend SQL to handle geometric objects: –OQL - Object Query Language (Object Database Management Group) –SDO - Spatial Database Option (Oracle Corp.) –PostgreSQL - open source Example: find all lakes (!) in Scotland (in the style of OQL): SELECT * FROM L in Lakes WHERE EXISTS (intersect(L.region, (SELECT C.polygon FROM C in Countries WHERE C.name = 'Scotland')));

14 Dept. of Computing Science, University of Aberdeen14 An Idealised Query Language Lets invent a new query language (based on functional programming): map = null; b = border(Countries, "Scotland"); for each l in Lakes() { s = intersect(l, b); if (exists(s)) { map = union(map, s); } Which do you prefer - SQL or functional programming? Real functional query languages exist, but mostly as research tools...

15 Dept. of Computing Science, University of Aberdeen15 Spatial Indexes Spatial DBs use a variety of techniques to accelerate spatial queries: –Bounding Boxes - simplify geometry tests: e.g. overlap –Grid Indexes - partition space –R-Trees - partition objects (R-Trees are like B-Tree with rectangular objects) Ideally, objects close together in space should be: –Close together in index; preferably on same index page Fundamental idea for indexing is to use approximations

16 Dept. of Computing Science, University of Aberdeen16 Bounding Box Spatial Indexes Rectangular boxes allow fast geometric filters to be applied - e.g. overlap Then, evaluate objects that pass filter using actual geometries However, every query requires a scan of the entire bounding box index

17 Dept. of Computing Science, University of Aberdeen17 Grid Indexes - Partitioning Space Divide space into a grid (the index): Simple, fast - provided grid fits into memory Works well if objects fit into grid cells...

18 Dept. of Computing Science, University of Aberdeen18 Summary Spatial DBs are useful for a wide range of applications... Special issues: –I/O - data collection (input) graphical displays (output) –need for abstract geometric data types and functions –need for special indexing techniques (R-trees) should existing SQL systems be adapted for geometric objects ? Overall: –spatial DBs aren't (shouldn't be) so different from conventional DBs


Download ppt "Spatial Databases Reading: None. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn the need for spatial databases some."

Similar presentations


Ads by Google