180 likes | 397 Views
Spatial Databases. Reading: None. 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.
E N D
Spatial Databases Reading: None
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 Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen
Special IssuesWith 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 Dept. of Computing Science, University of Aberdeen
Conceptual Modellingfor Spatial Databases • Conceptual modelling for spatial databases is similar to E-R modelling: • But there are some important differences: 0..* Has 1..1 Country Lake Dept. of Computing Science, University of Aberdeen
Logical Modelling - Using Relational Model Country Boundary Point Contour Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen
Problems with using RDBMS for Spatial Data • Formulating queries requires knowledge of the spatial object’s 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 Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen
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! Dept. of Computing Science, University of Aberdeen
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... Dept. of Computing Science, University of Aberdeen
Desirable Featuresfor 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 ? Dept. of Computing Science, University of Aberdeen
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'))); Dept. of Computing Science, University of Aberdeen
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... Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen
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... Dept. of Computing Science, University of Aberdeen
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 Dept. of Computing Science, University of Aberdeen